According to the OpenCV documentation cvLoadImage must return pointer to IplImage, but it looks like it is returning int.
when I run the below program, i get some warnings which is shown below program
#include "highgui.h"
#include <stdio.h>
int main(int argc, char** argv)
{
IplImage *img = cvLoadImage ("/path/to/file/face.jpg");
if(img != NULL)
printf("%d", img->width);
}
Also I am getting segmentation fault when I run the above code, I am guessing since img is a int so its causing crash when I am trying to access img->width, Warnings when above code is compiled
/usr/local/Cellar/opencv/3.3.0_3/include/opencv2/core/types_c.h:929:13: warning:
implicit declaration of function 'cvRound' is invalid in C99
[-Wimplicit-function-declaration]
ipt.x = cvRound(point.x);
^
main.c:7:21: warning: implicit declaration of function 'cvLoadImage' is invalid
in C99 [-Wimplicit-function-declaration]
IplImage *img = cvLoadImage ("/path/to/file/face.jpg");
^
main.c:7:15: warning: incompatible integer to pointer conversion initializing
'IplImage *' (aka 'struct _IplImage *') with an expression of type 'int'
[-Wint-conversion]
IplImage *img = cvLoadImage ("/path/to/file/face.jpg");
warning says incompatible converstion from int, so I have change the IplImage to int and it worked fine and it ourputs some negative integer value for img
#include "highgui.h"
#include <stdio.h>
int main(int argc, char** argv)
{
printf("%s\n","hello world");
int img = cvLoadImage ("/path/to/file/face.jpg");
printf("%d", img);
}
I get the below warnings for the above program
implicit declaration of function 'cvRound' is invalid in C99
[-Wimplicit-function-declaration]
ipt.x = cvRound(point.x);
^
main.c:7:15: warning: implicit declaration of function 'cvLoadImage' is invalid
in C99 [-Wimplicit-function-declaration]
int img = cvLoadImage ("/path/to/file/face.jpg");
I went sleepless to figure out it, google could not help, is it something to do with OpenCV versions or C versions?, I am using Opencv2 3.3.0, please feel free to ask if any information is required
cv.h? - Sourav GhoshcvLoadImageis not inhighguimodule, it's in imgcodecs -- perhaps#include "opencv2/imgcodecs/imgcodecs_c.h"? - Dan Mašek