openCV imread errors?

Hi all,

Does any body know if the supplied openCV libs have any limitation? I’m getting errors loading images through opencv.

Currently testing the cv libs like this:
Inside addons/ofxOpenCv/libs/opencv I create a test.c file:

  
  
#include "include/opencv2/opencv.hpp"  
#include "include/opencv/cv.h"  
#include <stdio.h>  
  
int main() {  
	cv::Mat loader = cvLoadImageM("/home/arnaud/Desktop/robot.png");  
	std::cout << loader.rows;  
}  
  

I then compile it like this:

  
  
$ gcc -c test.c -I include/  
$ g++ -o test test.o lib/linux64/libopencv_legacy.a lib/linux64/libopencv_objdetect.a lib/linux64/libopencv_features2d.a lib/linux64/libopencv_imgproc.a lib/linux64/libopencv_video.a lib/linux64/libopencv_highgui.a lib/linux64/libopencv_ml.a lib/linux64/libopencv_core.a -lz -lrt  
  

Executing it:

  
$ ./test   
0  
  

So it doesn’t load the image :frowning:

Changing the imread line to the C api:

  
cv::Mat loader = cvLoadImageM("/home/arnaud/Desktop/robot.png");  
  

and executing it:

  
$ ./test   
Segmentation fault (core dumped)  
  

The reason I use opencv to load images is that ofImage is limited to the GPU. At least loading huge images results in a white image… I read on the forum it’s because of GPU limitiations…

Testing with develop branch on linux64…

Now compiling openCV 2.4 in the background…

Rg,

Arnaud

I guess I can answer my own question. The supplied openCv libs are compiled without any image loading support. My own compiled opencv works fine :S

So back to using ofImage…

Rg,

Arnaud

Hi Arnaud,

yeah, the official way to have images in openCv is to use ofImage.

FYI if you have a segmentation fault or a crash you can often debug it using gdb, especially if you have built for Debug. just run gdb passing the name of the executable, ie:

  
cd bin  
gdb ./graphicsExample  

type ‘r’ to run the app. when it crashes, you can type ‘bt’ to get a stack backtrace and that will tell you exactly where it’s crashing. you can use ‘up’ and ‘down’ to move up and down the call stack, ‘list’ to list the code at the current stack frame and ‘print’ to display the contents of variables. you can set breakpoints, dump memory, change variables values, and all sorts of other fun stuff. type ‘help’ for a full list of commands.

cheers
damian

Thnx for the hint. F8 in codeblocks does the same :slight_smile: