Super beginner opencv hello world


#1

hi!
i’ve just bought Learning Opencv from O’Reilly and i want to make the examples in openframework (i’m on ubuntu)
and i have 2 question:

  1. i’ve tried to copy the first hello world inside an emptyExample (yeah ok i know that this is dumb), and so i have this code in my draw function:
  
void testApp::draw() {  
{  
  IplImage* img = cvLoadImage( argv[1] );  
  cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );  
  cvShowImage("Example1", img );  
  cvWaitKey(0);  
  cvReleaseImage( &img );  
  cvDestroyWindow("Example1");  
}  

i can compile but i have this runtime error (i’m using makefile):

$ make; cd bin; ./emptyExample
cp -r …/…/…/export/linux/libs bin/

compiling done
to launch the application

cd bin
./emptyExample

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/arturo/Downloads/OpenCV-2.2.0/modules/highgui/src/window.cpp, line 274
terminate called after throwing an instance of ‘cv::Exception’
what(): /home/arturo/Downloads/OpenCV-2.2.0/modules/highgui/src/window.cpp:274: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

Aborted

some advice?

  1. i’ve downloaded the examplefiles from oreilley websites and there are .cpp files. but that code is c or cpp code (i think that it is simple c and not cpp)? some advice on how to adapt the c code to cpp openframeworks code?

[EDIT underdoeg: fixed typo in title]


#2

Hi

  1. i’ve tried to copy the first hello world inside an emptyExample (yeah ok i know that this is dumb), and so i have this code in my draw function:

Not that dumb, but if you copy a code like this, I’d at least put it into setup(), so it will only get called once. But to get started on using openCV with openframeworks, take a look at the ofxOpenCV addon which is included with OF.

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/arturo/Downloads/OpenCV-2.2.0/modules/highgui/src/window.cpp, line 274

This says pretty much what you have to do. You should rebuild the openCV library, but first install libgtk2.0-dev and pkg-config via synaptic package manager and then run the configure script again.

But on ubuntu you can also install openCV without having to compile it for yourself. To see how, check this wiki entry for example: https://help.ubuntu.com/community/OpenCV Or just use the precompiled openCV library that comes with ofxOpenCV. (just write ofxOpenCv into the addons.make file in your project folder).

  1. i’ve downloaded the examplefiles from oreilley websites and there are .cpp files. but that code is c or cpp code (i think that it is simple c and not cpp)? some advice on how to adapt the c code to cpp openframeworks code?

You can mix c and c++ code almost without any issues. I also think the makefile should find any c files and compile them automatically? If not, just rename them to cpp, that should work.


#3

hei, thanks!
yeah, you’re right for the setup and draw!

i was wondering about some weirdness, like to use a different renderer (highgui)

thanks for point me to ofxOpenCV. addons often has good advantage to speed up the works but sometimes i prefer to deal with things from scratch for better understanding.

ohu, yeah, i’ve already installed opencv in ubuntu, thanks anyway!


#4

Hello, i have this same error but using the ofxOpenCV addon in a project, developing in Visual Studio 2015 on Windows 7. I tried to rebuild the project/solution but it didn’t work. I have been trying to rebuild the ofxOpenCv but don’t see any way through it. Would thank any help.