根據OpenCV文檔,cvLoadImage必須返回指向IplImage的指針,但看起來它正在返回int。cvLoadImage返回int?
當我運行下面的程序,我得到一些警告,這顯示在下面的程序
#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);
}
而且我得到段錯誤,當我運行上面的代碼,因爲IMG我猜是INT所以其造成當我試圖訪問img->寬度崩潰,警告時上面的代碼被編譯
/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");
警告說,從int不相容converstion,所以我必須改變的IplImage爲int和它的工作很好,我牛逼ourputs爲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);
}
我得到下面的警告,上述程序
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");
我去眠弄清楚它,谷歌不能幫助,是它的東西做OpenCV版本或C版本?我使用Opencv2 3.3.0,請隨時詢問是否需要任何信息
你缺少一個頭文件(函數的前向聲明)。 –
@Sourav Ghosh,可能是,但不知道你嘗試添加'cv.h'的哪一個 –
? –