Results 1 to 7 of 7

Thread: Trouble With OpenCV on 11.3

  1. #1

    Question Trouble With OpenCV on 11.3

    Trying to learn a bit of OpenCV. I installed version 2.1 from the KDE Stable repo.

    Code:
    #include <stdio.h>
    #include "highgui.h"
    
    int main(int argc, char** argv) {
    	IplImage* img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
    	cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);
    	cvShowImage("Example1", img);
    	cvWaitKey(0);
    	cvReleaseImage(&img);
    	cvDestroyWindow("Example1");
    }
    After compiling and running the program with a png filename as an arg I get the following on stdout:

    Code:
    libpng error: invalid code lengths set
    
    (Example1:6255): GLib-GObject-CRITICAL **: g_param_spec_double: assertion `default_value >= minimum && default_value <= maximum' failed
    
    (Example1:6255): GLib-GObject-CRITICAL **: g_object_class_install_property: assertion `G_IS_PARAM_SPEC (pspec)' failed
    
    (Example1:6255): GLib-GObject-WARNING **: IA__g_object_notify: object class `GdkScreenX11' has no property named `resolution'
    I've spent some time searching, but I've not come across anyone having a similar problem (makes me think I'm overlooking something simple?).

    After creating a png file with GIMP I've found that the program works with png images that aren't compressed. I'm kinda stuck understanding what's wrong here.... Any ideas?

    Another problem I've encountered was with the next example I tried, which is supposed to be passed the name of an avi file for playback:

    Code:
    #include <stdio.h>
    #include "highgui.h"
    
    int main(int argc, char **argv) {
    	cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE);
    	CvCapture *capture = cvCaptureFromFile(argv[1]);
    	IplImage *frame;
    	while (1) {
    		frame = cvQueryFrame(capture);
    		if (!frame) break;
    		cvShowImage("Example2", frame);
    		char c = cvWaitKey(33);
    		if (c == 27) break;
    	}
    	cvReleaseCapture(&capture);
    	cvDestroyWindow("Example2");
    }
    And the output...

    Code:
    params.c:OpenConfFile() - Unable to open configuration file "/home/steve/.smb/smb.conf":
            No such file or directory
    params.c:OpenConfFile() - Unable to open configuration file "/home/steve/.smb/smb.conf.append":
            No such file or directory
    Illegal instruction
    smb.conf belongs to samba, no? What does that have to do with grabbing frames from an avi file? My first experience working with the OpenCV lib hasn't been pleasant so far. I'd appreciate if anyone can pass me a few pointers as to what I'm doing wrong, or to help me find out if something isn't configured properly....

    I compiled the examples with gcc 4.5 like so:

    Code:
    gcc -I/usr/include/opencv -lhighgui -o example2_1 example2_1.c
    I even tried compiling OpenCV 2.1 from source. I succeeded after a few hurdles (like needing to add the "-D__STDC_CONSTANT_MACROS" cxx flag because of an ffmpeg header, and the whole png12/png14 thing). After compilation I still get the same errors.

    Sigh...
    openSUSE 11.3 with KDE 4.4.4

  2. #2

    Default Re: Trouble With OpenCV on 11.3

    Both examples work fine here using opencv from home:RedDwarf:multimedia (that is the same version from KDEistro:Factory but compiled with ffmpeg support)

    Used /usr/share/icons/hicolor/32x32/apps/vlc.png for the PNG case.

  3. #3

    Default Re: Trouble With OpenCV on 11.3

    Hmm... I forgot to pay attention to repo priorities and so when I installed using zypper it pulled in opencv from KDE Stable.

    I've since installed opencv from packman and it works better. With the first example I still can't load a compressed png (not that it matters, just can't understand why not).

    @RedDwarf: I tried opencv from your repo, but with the first example the program always fails with the message "Illegal instruction" on stdout when given a png file. Works fine with a jpg image, though. The second example works fine too.

    I tried another example:

    Code:
    #include <stdio.h>
    #include "cv.h"
    #include "highgui.h"
    
    void example2_4(IplImage *);
    
    int main(int argc, char **argv) {
    	IplImage *img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
    	example2_4(img);
    	return 0;
    }
    
    void example2_4(IplImage *img) {
    	cvNamedWindow("Example4-in", CV_WINDOW_AUTOSIZE);
    	cvNamedWindow("Example4-out", CV_WINDOW_AUTOSIZE);
    
    	cvShowImage("Example4-in", img);
    
    	IplImage *out = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3);
    	cvSmooth(img, out, CV_GAUSSIAN, 3, 3, 0, 0);
    	cvShowImage("Example4-out", out);
    	cvReleaseImage(&out);
    
    	cvWaitKey(0);
    
    	cvDestroyWindow("Example4-in");
    	cvDestroyWindow("Example4-out");
    }
    When the program gets to the point of displaying "out"(when using opencv from Packman or your repo), it fails with:

    Code:
    example2_4: cairo-surface.c:861: cairo_surface_set_device_offset: Assertion `status == CAIRO_STATUS_SUCCESS' failed.
    Aborted
    How does this program go for you? I had to improvise with calling cvSmooth, so I'm not sure if that could be the problem. Or, maybe we need to wait until Packman packages cairo?

    I'm lost... maybe my computer just sucks, or is screwed up somewhere?
    openSUSE 11.3 with KDE 4.4.4

  4. #4

    Default Re: Trouble With OpenCV on 11.3

    Quote Originally Posted by tokostok View Post
    @RedDwarf: I tried opencv from your repo, but with the first example the program always fails with the message "Illegal instruction" on stdout when given a png file. Works fine with a jpg image, though. The second example works fine too.
    I just looked into it. It uses SSE and SSE2 instructions... technically wrong for a i586 package (that I suppose you are using). Probably your CPU doesn't supports such extensions.

    Quote Originally Posted by tokostok View Post
    I tried another example:

    Code:
    #include <stdio.h>
    #include "cv.h"
    #include "highgui.h"
    
    void example2_4(IplImage *);
    
    int main(int argc, char **argv) {
    	IplImage *img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
    	example2_4(img);
    	return 0;
    }
    
    void example2_4(IplImage *img) {
    	cvNamedWindow("Example4-in", CV_WINDOW_AUTOSIZE);
    	cvNamedWindow("Example4-out", CV_WINDOW_AUTOSIZE);
    
    	cvShowImage("Example4-in", img);
    
    	IplImage *out = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3);
    	cvSmooth(img, out, CV_GAUSSIAN, 3, 3, 0, 0);
    	cvShowImage("Example4-out", out);
    	cvReleaseImage(&out);
    
    	cvWaitKey(0);
    
    	cvDestroyWindow("Example4-in");
    	cvDestroyWindow("Example4-out");
    }
    When the program gets to the point of displaying "out"(when using opencv from Packman or your repo), it fails with:

    Code:
    example2_4: cairo-surface.c:861: cairo_surface_set_device_offset: Assertion `status == CAIRO_STATUS_SUCCESS' failed.
    Aborted
    How does this program go for you? I had to improvise with calling cvSmooth, so I'm not sure if that could be the problem. Or, maybe we need to wait until Packman packages cairo?
    Again works just fine here. Both the VLC icon (that I passed through optipng to be sure it was "compressed") and an smoothed version are shown.

  5. #5

    Default Re: Trouble With OpenCV on 11.3

    I went back to building opencv from source. Paying closer attention I realized that I didn't configure the path (oops). What ended up happening was that the example executables were being linked against the opencv libs from package libopencv2. This time I created the file "opencv.conf" in "/etc/ld.so.conf.d/" with the line "/usr/local/lib" (as the default installation dir was /usr/local/), ran "ldconfig", and voila! Every example is working as it's suppossed to.

    The rpm pkgs (from any repo I've tried) just don't work for me atm. But I'm happy that building from source has finally paid off.

    Just a couple of notes for anyone that might want to build opencv from source:
    1.For me make failed because of a certain ffmpeg header (don't remember which). If anyone runs into this problem the solution was to add a cxx flag, "-D__STDC_CONSTANT_MACROS". I added this flag, using cmake-gui, to the field "OPENCV_EXTRA_C_FLAGS".
    2.There is a problem when compiling opencv against png14 headers. I think you have to apply a patch to the code somehow. I don't know how. What I did was to install the png12 headers (zypper in libpng12-0 libpng12-devel libpng12-compat-devel).

    @RedDwarf: tyvm for your help. If you hadn't replied to my thread and hadn't tried out the examples for me, it's possible I would have dropped my interest in opencv. I guess now it's back to rtfm.
    openSUSE 11.3 with KDE 4.4.4

  6. #6

    Default Re: Trouble With OpenCV on 11.3

    Quote Originally Posted by tokostok View Post
    The rpm pkgs (from any repo I've tried) just don't work for me atm. But I'm happy that building from source has finally paid off.
    If you are using the i586 package and your CPU doesn't supports SSE2 (Pentium 3 or older, or pre-K8 Athlons) you should open a bug report. Probably directly against opencv.
    SSE2 was enabled because in the latest opencv chagelog it was said that the CPU support would be detected at runtime. It seems the detection doesn't works.

    Quote Originally Posted by tokostok View Post
    1.For me make failed because of a certain ffmpeg header (don't remember which). If anyone runs into this problem the solution was to add a cxx flag, "-D__STDC_CONSTANT_MACROS". I added this flag, using cmake-gui, to the field "OPENCV_EXTRA_C_FLAGS".
    Yes, it's a sorry state. C99 added the macro but C++ still doesn't has it. I added a patch to my false ffmpeg package, but neither ffmpeg or Packman wanted it: https://build.opensuse.org/package/v...rf:fakePackman

    Quote Originally Posted by tokostok View Post
    2.There is a problem when compiling opencv against png14 headers. I think you have to apply a patch to the code somehow. I don't know how. What I did was to install the png12 headers (zypper in libpng12-0 libpng12-devel libpng12-compat-devel).
    It's just a line, in fact seven chars: https://build.opensuse.org/package/v...Distro:Factory

  7. #7
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,846
    Blog Entries
    15

    Default Re: Trouble With OpenCV on 11.3

    @RedDwarf
    Can you do me a favor and branch my package eviacm and build against
    your version of opencv for me to test?
    https://build.opensuse.org/package/f...olmlewis%3AGtk

    I can get the app to work on the old pacman version 2.0.0 but not the
    latest.

    --
    Cheers Malcolm (Linux Counter #276890)
    openSUSE 11.3 (x86_64) Kernel 2.6.34.4-0.1-default
    up 1 day 1:39, 3 users, load average: 0.16, 0.12, 0.04
    GPU GeForce 8600 GTS Silent - Driver Version: 256.53


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •