Ask Your Question
0

How to compile Opencv C files ??

asked 2013-01-11 22:30:20 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

how to compile opencv C files ?

I’m reading Learning opencv computer vision with opencv library.

I have this error with the first example I made.

#include "highgui.h" // I tried using with <opencv/highgui.h> but it keep showing the same error

int main(int argc, char** argv ){


IplImage* img = cvLoadImage( argv[1]);

cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );

cvShowImage("Example1" , img );

cvWaitKey(0);

cvReleaseImage( &img );

cvDestroyWindow( "Example1" );

}

I compile using this command g++ -o example example.c pkg-config --cflags --libs opencv

user@usermob:~/tesOpen$ ./test 

libusb: 0.000000 debug [libusb_init] libusb-1.0.9 git:1.0.9-28-g7634714

libusb: 0.000068 debug [find_usbfs_path] found usbfs at /dev/bus/usb

libusb: 0.000134 debug [op_init] bulk continuation flag supported

libusb: 0.000164 debug [op_init] zero length packet flag supported

libusb: 0.000204 debug [op_init] found usb devices in sysfs

libusb: 0.000302 debug [usbi_add_pollfd] add fd 4 events 1

libusb: 0.000346 debug [usbi_io_init] using timerfd for timeouts

libusb: 0.000369 debug [usbi_add_pollfd] add fd 6 events 1

terminate called after throwing an instance of 'std::logic_error'

  what():  basic_string::_S_construct null not valid

Aborted (core dumped)
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2013-01-12 03:31:50 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

You are asking for argv[1] but you did not pass ./test any arguments? Also your g++ command saves to ./example not ./test. Are these typos or could that be your issue?

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-01-11 22:30:20 -0600

Seen: 6,140 times

Last updated: Jan 12 '13