Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

How to link to OpenCV goodies for PERL5

by freddythunder (Novice)
on Jun 09, 2013 at 00:23 UTC ( [id://1037892]=perlquestion: print w/replies, xml ) Need Help??

freddythunder has asked for the wisdom of the Perl Monks concerning the following question:

Hello. Brand new to perl but have been a PHP guy for many moons. I was led to perlmonks from someone on crunchbang linux forums and I hope someone can help. Yesterday I started getting into opencv for use with my linux box. After some struggling and making the whole thing a couple times, I finally got one of the tutorials to work in C++. But when I try to run a script from perl, it says this:

[Sat Jun 08 17:04:41 2013] [error] [client 192.168.1.1] /usr/bin/perl: + symbol lookup error: /usr/local/lib/perl/5.14.2/auto/Image/ObjectDet +ect/ObjectDetect.so: undefined symbol: cvLoad [Sat Jun 08 17:04:41 2013] [error] [client 192.168.1.1] Premature end +of script headers: open1.pl

I looked and /usr/local/lib/perl/5.14.2/auto/Image/ObjectDetect/OpbjectDetect.so is right there and is read/execute for everyone, plus I've tried running the perl script from cgi-bin and sudo from the command line. I echoed $PERL5LIB var to see what the path was and it was blank. I know perl is working because my other perl starting out tutorials work fine. I added /usr/include and /usr/include/opencv to the path but I don't think that makes a difference. Here is the little script that is supposed to find faces in a picture:

#! /usr/bin/perl use Image::ObjectDetect; my $cascade = 'haarcascade_frontalface_alt2.xml'; my $file = 'picture.jpg'; my $detector = Image::ObjectDetect->new($cascade); @faces = $detector->detect($file); for my $face (@faces) { print $face->{x}, "\n"; print $face->{y}, "\n"; print $face->{width}, "\n"; print $face->{height}, "\n"; }

Easy right? I hope someone can help. I would rather use perl than c++ and skip that whole compilation step.

Replies are listed 'Best First'.
Re: How to link to OpenCV goodies for PERL5
by Anonymous Monk on Jun 09, 2013 at 03:54 UTC

    Run ldd -v ...14.2/auto/Image/ObjectDetect/ObjectDetect.so to diagnose the issue,

    Then adjust your LD_LIBRARY_PATH accordingly or recompile ObjectDetect and/or its dependencies

      Thank you so much Anonymous Monk! But I'm still a touch green. I tried adjusting this like so to no avail:

      freddythunder@tacofever:/usr/lib/cgi-bin$ export LD_LIBRARY_PATH=/lib/ +x8664-linux-gnu

      Here is my output of ldd:

      freddythunder@tacofever:/usr/lib/cgi-bin$ ldd -v /usr/local/lib/perl/5 +.14.2/auto/Image/ObjectDetect/ObjectDetect.so linux-vdso.so.1 => (0x00007fff5ddff000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f055912e000) /lib64/ld-linux-x86-64.so.2 (0x00007f05596d1000) Version information: /usr/local/lib/perl/5.14.2/auto/Image/ObjectDetect/ObjectDetect.so +: libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6: ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so. +2 ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64 +.so.2

      I also wonder if I need to restart any service when I make these changes like PHP. I know if you adjust those you have to restart apache to see the changes take effect. I have been testing from command line BTW.

      I need some more detail on how to recompile ObjectDetect if I need to do that instead. Compiling everything I need is still pretty new to me. Thanks!

Re: How to link to OpenCV goodies for PERL5
by hbm (Hermit) on Jun 09, 2013 at 13:49 UTC
    I looked and /usr/local/lib/perl/5.14.2/auto/Image/ObjectDetect/OpbjectDetect.so is right there and is read/execute for everyone

    The trouble is, "cvLoad" is not defined, right?

    /usr/bin/nm -n /usr/local/lib/perl/5.14.2/auto/Image/ObjectDetect/Obje +ctDetect.so |grep -i cvload

    How did you install Image::ObjectDetect? Review the 'make' output for clues. If you didn't capture it, you can run 'Makefile.PL' and 'make' manually against the source. Also check the module's bug reports on CPAN.

    And a suggestion for your printing:

    print join "\n", $face->{x}, $face->{y}, $face->{width}, $face->{height};

      I ran /usr/bin/nm and it reads that cvLoad and cvLoadImage are Undefined. That can't be good.

      I originally loaded opencv via the instructions at opencv and then later followed the instructions found here:

      http://linuxgazette.net/176/misc/lg/face_detection_in_perl.html

      I tried cpan Image::ObjectDetect again and it tells me that it is installed and up to date.

      I would try to make manually against the source, but I don't know where the source is. I found this to help me:

      http://world.std.com/~swmcd/steven/perl/module_mechanics.html#TOC19

      When I google for more information I get this thread...

      Thanks for your help, I will change the printing if it ever works ;)

        When you install modules with CPAN, the source is first downloaded to your .cpan directory - should be in the home directory of whatever account you installed with.

        1. 'find' or 'locate' the source (under the author)
        2. Change to that directory
        3. /path/to/perl Makefile.PL
        4. make > make.log 2>&1

        Hopefully make.log will then get you closer to the root cause.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1037892]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-25 14:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found