AVT Cameras segfault (use of flag CV_CAP_PVAPI) (Patch #1771)
Description
I build opencv WITH_PVAPI flag and install it on my Linux Xubuntu 11.10 (x86_64) with 3.0.0-17-generic linux kernel.
My camera is Manta G-032, I tried put it to work with opencv using the below example program:
1#include <stdio.h>
2#include <opencv/highgui.h>
3
4int main( int argc, char** argv )
5{
6 cvNamedWindow("Example", CV_WINDOW_AUTOSIZE);
7 CvCapture* capture = cvCreateCameraCapture(CV_CAP_PVAPI);
8 assert(capture != NULL);
9 IplImage* frame;
10
11 while(1)
12 {
13 frame = cvQueryFrame(capture);
14 if(!frame) break;
15 cvShowImage("Example", frame);
16 char c = cvWaitKey(13);
17 if(c == 27) break;
18 }
19 cvReleaseCapture(&capture);
20 cvDestroyWindow("Example");
21 return 0;
22}
The result of this program is a segfault. After of navigate on google and analyse the codes cap_pvapi.cpp from opencv and StreamAndGrab.cpp from AVT GigE SDK code I can solve the problem.
On PvAPI of opencv is missing a 'memset' of structure tCamera as StreamAndGrab.cpp code.
I put the follow line: memset(&capture->Camera, 0, sizeof(tCamera));
just after of object CvCaptureCAM_PvAPI creation.
Associated revisions
Fixed cameras segfault (patch #1771)
Merge pull request #1771 from kiranpradeep:2.4
History
Updated by Andrey Kamaev almost 13 years ago
- Tracker changed from Bug to Patch
- Target version set to 2.4.0
- Description changed from I build opencv WITH_PVAPI flag and install it on my Linux Xubuntu 11.10 (x86_... to I build opencv WITH_PVAPI flag and install it on my Linux Xubuntu 11.10 (x86_... More
Updated by Alexander Reshetnikov almost 13 years ago
Ricardo, thank you for the patch! It was applied in r8011
- Status changed from Open to Done
Updated by Andrey Kamaev almost 13 years ago
This change results in build error (with AVT PvAPI GigE SDK 1.26 for Linux):
[ 29%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_pvapi.cpp.o /home/andreyk/OpenCV2/2.4/opencv/modules/highgui/src/cap_pvapi.cpp: In function ‘CvCapture* cvCreateCameraCapture_PvAPI(int)’: /home/andreyk/OpenCV2/2.4/opencv/modules/highgui/src/cap_pvapi.cpp:101: error: ‘CvCaptureCAM_PvAPI::tCamera CvCaptureCAM_PvAPI::Camera’ is protected /home/andreyk/OpenCV2/2.4/opencv/modules/highgui/src/cap_pvapi.cpp:361: error: within this context /home/andreyk/OpenCV2/2.4/opencv/modules/highgui/src/cap_pvapi.cpp:361: error: ‘tCamera’ was not declared in this scope make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_pvapi.cpp.o] Error 1
- Status changed from Done to Open
Updated by Ricardo Crudo almost 13 years ago
Sorry, on my tests I had changed the struct tCamera to global scope and the Camera variable to public member. This is not a good idea. The right thing to do is put the memset on class constructor, like below:
CvCaptureCAM_PvAPI::CvCaptureCAM_PvAPI() { monocrome=false; memset(&this->Camera, 0, sizeof(this->Camera)); }
Please, disregard the file that I had attached previously.
Best Regards,
Ricardo.
Updated by Alexander Reshetnikov almost 13 years ago
- Status changed from Open to Done
Updated by Andrey Kamaev over 12 years ago
- Category changed from highgui-images to highgui-camera