Ask Your Question
0

OpenCV problem

asked 2015-12-27 11:55:21 -0500

RO-ny9 gravatar image

updated 2015-12-27 20:19:42 -0500

Hi, I download and install OpenCV 3.1, but when I want to start a code it wrote me back this error message

CODE

#include "highgui.h"

int main(void)
{
 cvNamedWindow("Demo", CV_WINDOW_AUTOSIZE);
 cvCapture* capture = cvCreateCameraCapture(0);
 IplImage* frame;
 while(1)
 {
      frame = cvQueryFrame(capture);
      if(!frame)break;
      cvShowImage("Demo",frame);
      char c = cvWaitKey(33);
      if(c==27)break;
 }
 cvReleaseCapture(&capture);
 cvDestroyWindow("Demo");
 return 0;
 }

here is my error message

CMakeFiles/camera.dir/camera.c.o: In function `cvPointFrom32f':
camera.c:(.text+0x7a4): undefined reference to `cvRound'
camera.c:(.text+0x7bc): undefined reference to `cvRound'
CMakeFiles/camera.dir/camera.c.o: In function `cvReadInt':
camera.c:(.text+0x1378): undefined reference to `cvRound'
CMakeFiles/camera.dir/camera.c.o: In function `cvEllipseBox':
camera.c:(.text+0x169c): undefined reference to `cvRound'
camera.c:(.text+0x16bc): undefined reference to `cvRound'
collect2: ld returned 1 exit status
CMakeFiles/camera.dir/build.make:113: recipe for target 'camera' failed
make[2]: * [camera] Error 1
CMakeFiles/Makefile2:63: recipe for target 'CMakeFiles/camera.dir/all' failed
make[1]: * [CMakeFiles/camera.dir/all] Error 2
Makefile:75: recipe for target 'all' failed
make: * [all] Error 2

please what I have to do to solve this problem? :)

edit retag flag offensive close merge delete

Comments

1

please show us your cmdline (you're probably not linking something)

berak gravatar imageberak ( 2015-12-27 12:58:47 -0500 )edit

here is my code

#include "highgui.h"

int main(void)

{

cvNamedWindow("Demo", CV_WINDOW_AUTOSIZE);


cvCapture* capture = cvCreateCameraCapture(0);


IplImage* frame;

while(1);

{

frame = cvQueryFrame(capture);

if(!frame)break;

cvShowImage("Demo",frame);

char c = cvWaitKey(33);

if(c==27)break;

}

cvReleaseCapture(&capture);

cvDestroyWindow("Demo");

return 0;

}
RO-ny9 gravatar imageRO-ny9 ( 2015-12-27 20:13:44 -0500 )edit
4

unfortunately this is using opencv's deprecated c-api. please try to avoid any of it, and instead use cv::Mat, cv::VideoCapture , cv::imshow(), etc.

berak gravatar imageberak ( 2015-12-28 01:39:49 -0500 )edit

Hi, please can you tell me which of that are deprecated?? or where can I find new one? :)

RO-ny9 gravatar imageRO-ny9 ( 2015-12-28 06:46:09 -0500 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2015-12-28 07:00:15 -0500

berak gravatar image

updated 2015-12-28 07:20:56 -0500

"can you tell me which of that are deprecated??" - ALL of them..

it's probably a good idea, to take a look at the tutorials , and use code like below to access the webcam:

#include "opencv2/opencv.hpp"
using namespace cv;

int main()
{
    VideoCapture cap(0); // get 1st cam
    while( cap.isOpened() )
    {
        Mat frame;
        if ( ! cap.read(frame) )
            break;

        // process your frame here..

        imshow("lalala",frame);
        int k = waitKey(10);
        if ( k==27 )
            break;
    }
    return 0;
}

and link it like:

g++ my.cpp -lopencv_core -lopencv_highgui -lopencv_videoio -o myfirstwebcam
edit flag offensive delete link more

Comments

thanks, I tried this code, and I tried another one, but in both cases it wrote me back this error message...

Xlib: extension "RANDR" missing on display ":1.0". libv4l2: error setting pixformat: Device or resource busy VIDEOIO ERROR: libv4l unable to ioctl S_FMT libv4l2: error setting pixformat: Device or resource busy libv4l1: error setting pixformat: Device or resource busy VIDEOIO ERROR: libv4l unable to ioctl VIDIOCSPICT

RO-ny9 gravatar imageRO-ny9 ( 2015-12-28 16:26:10 -0500 )edit

Does that mean that I must use OpenCV version 2.4.11 if I want to use C code ?

Is it right to say that OpenCV 3.1 doesn't support capture from a device in a C program ?

What about embedded devices ? I got the same error on a Raspberry Pi after updating to OpenCV 3.1 cvCapture* capture = cvCreateCameraCapture(0) does not work.

What is the definition of Deprecated ? Is it still permitted or not permitted to use C code with OpenCV 3.1 ?

ssinfod gravatar imagessinfod ( 2016-01-05 14:16:25 -0500 )edit

^^ no, that means, that you should not use the deprecated c-api at all .

you will gain nothing from using c here, all c-api calls are actually emulated via c++ api, so just use that.

berak gravatar imageberak ( 2016-01-05 21:54:47 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-12-27 11:55:21 -0500

Seen: 3,241 times

Last updated: Jan 05 '16