나는 Bradsky와 Kaehler의 oPENCV, o'Reilly를 배웠습니다. 나는 우분투 10.10에있어, 이전 예제는 잘 작동하지만 2-4에서는 문제가있다.O'Reilly의 Opencv Learning 연습 문제 2-4
#include "cv.h"
#include "highgui.h"
void example2_4(IplImage* image)
{
// Create some windows to show the input
// and output images in.
//
cvNamedWindow("Example2_4-in", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Example2_4-out", CV_WINDOW_AUTOSIZE);
// Create a window to show our input image
//
cvShowImage("Example2_4-in", image);
// Create an image to hold the smoothed output
//
IplImage* out = cvCreateImage(
cvGetSize(image),
IPL_DEPTH_8U,
3
);
// Do the smoothing
//
cvSmooth(image, out, CV_GAUSSIAN, 5,5);
cvSmooth(out, out, CV_GAUSSIAN, 5, 5);
// Show the smoothed image in the output window
//
cvShowImage("Example2_4-out", out);
// Be tidy
//
cvReleaseImage(&out);
// Wait for the user to hit a key, then clean up the windows
//
cvWaitKey(0);
cvDestroyWindow("Example2_4-in");
cvDestroyWindow("Example2_4-out");
}
int main(int argc, char** argv)
{
IplImage* img = cvLoadImage(argv[1]);
cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);
cvShowImage("Example1", img);
example2_4(img);
// cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Example1");
}
이 오류입니다 :
이
코드입니다[email protected]:/tmp$ g++
pkg-config opencv --cflags --libs
ch2_ex2_4.cpp [email protected]:/tmp$ ./a.out tree.avi OpenCV Error: Bad argument (Array should be CvMat or IplImage) in cvGetSize, file /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp, line 1233 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp:1233: error: (-5) Array should be CvMat or IplImage in function cvGetSizeAborted
가 무엇을 할 수있는가? 몇개의 충고?? 나는 예제를 수정하지 않았고 방금 opencv를 시냅틱과 함께 다운로드 했으므로 마지막 버전이라고 생각한다!
컴파일 오류가 아닌 런타임 오류입니다. 제목을 – john
으로 변경했습니다. 'opencv'를 모르지만 코드의 어느 줄에서 오류가 발생하는지 확인할 수 있습니다 몇 개의'cout' 문장. – Beta
유효한 이미지를 인수로 사용하여이 샘플을 실행 했습니까? FYI : 최신 OpenCV 버전은 2.3.1입니다. –