opencv - strange cvSaveImage behavior -


I've recently started using opencv and it has baffled me // data four [height * Width] {char fName [200] = "c: void saveImageSnippet (char * imageName, int height, int width, zero * data, int nChannels) \\ testimg \\"; FILE * fptr; IplImage * img; Sprintf (fName, "% s% s.bmp", fName, imageName); Img = cvCreateImageHeader (cvSize (width, height), 8 / * deeply * /, NChannels); Img-> ImageData = (unsigned char *) data; CvSaveImage (fName, IMG); // Unsolicited exception cvReleaseImage (& amp; img); }

On cvSaveImage: unwanted exceptions vc2008_1x.exe in 0x6e8e871d: 0xC0000005: what access violation reading location 0x745c3a63'm something that I do not?

Now an interesting part is, if I add some unused variables, cvSaveImage works just fine

  zero saveImageSnippet (char * imageName, integer height, int width, Void * data, int nachanal) {int var1, var2; // unused variable char fName [200] = "c: \\ testimg \\"; FILE * fptr; IplImage * img; Sprintf (fName, "% s% s.bmp", fName, imageName); Img = cvCreateImageHeader (cvSize (width, height), 8 / * deeply * /, NChannels); Img-> ImageData = (unsigned char *) data; CvSaveImage (fName, IMG); // Now it works fine cvReleaseImage (& amp; img); }  "post-text" itemprop = "text"> 

Please use OpenCV's C + API, do not avoid anything, which has iplagames in it (especially SO!)

  #include "opencv2 / highgui.hpp" // no, * not * highgui.h! Using namespace cv; Int main () {string fName = format ("c: \\ testimg \\% s.bmp", imageName); Mat img = imread (fName); If (img.empty ()) -1 return; // Your Image Impression (FNAM) was not loaded; Return 0; }  

Comments

Popular posts from this blog

c# - WPF Expander overlay used in ItemsControl -

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

Android studio res/xml directory not found -