0

I am aware my question is similar to:

OpenCV 2.0 C++ API using imshow: returns unhandled exception and "bad-flag"

Though I hv tried all the suggested and verified solutions from this page as well as other related pages, I still face the same problem of corrupted window names. Here is my code:

#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <string.h>   
#include <malloc.h>   
#include <math.h>   
#include"ip.h"  
#include"histogram.h"
#include <opencv2\highgui\highgui.hpp>
#include "opencv2/core/core.hpp"

using namespace cv;
using namespace std;

void main()
{
    IplImage *img01 = cvLoadImage("E:\liberty.jpg",CV_LOAD_IMAGE_GRAYSCALE);
    cv::Mat img1(img01, false);
    cv::namedWindow("Image 1");
    cv::imshow("Image 1",img1);
    cv::waitKey(0);
    cv::destroyWindow("Image 1");
}

What should i do?Please help.

Community
  • 1
  • 1
cappy0704
  • 557
  • 2
  • 9
  • 30

1 Answers1

0

Is your image loading to img01?

Try changing '\' to'/' in IplImage *img01 = cvLoadImage("E:\liberty.jpg",CV_LOAD_IMAGE_GRAYSCALE);

Pranjal
  • 96
  • 3
  • Pranjal, the image loads. Tried ur method. Still the same problem. – cappy0704 May 06 '13 at 14:11
  • All I did was change the '\' and it worked for me. So maybe you need to check your libraries - you've used both _# include " "_ & _# include < >_ for linking to the OpenCV libs - just wondering – Pranjal May 06 '13 at 15:07
  • Ur guess is as good as mine @Pranjal. #include"..." is for user defined headers and <..> is pre defined headers. So that doesnt make too much difference. as for the libraries, i have added all of them, and double checked with the dlls too. Unfortunately still the same. Did u implement this very program? – cappy0704 May 06 '13 at 16:16
  • I'm guessing you've tried all of this, but if it's any use, try - http://www.youtube.com/watch?v=cgo0UitHfp8 – Pranjal May 06 '13 at 17:06