Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 24 Oct 2014, 04:40
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How To Install OpenCV computer vision library on Puppy
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [14 Posts]  
Author Message
jyore


Joined: 06 Nov 2010
Posts: 43

PostPosted: Fri 12 Nov 2010, 18:54    Post subject:  How To Install OpenCV computer vision library on Puppy
Subject description: Seeing Eye Puppy
 

*******************
Verified Installs
*******************
- Original install by myself on Puppy 4.3.1
- Secondary install by myself on Puppy 4.3.0 (from fresh puppy install)
- Install by swindler on Puppy 4.3.1 (from fresh install)
*******************

I finally got OpenCV installed and running after many frustrating hours of hacking at terminal commands and tracking down libraries. Turns out it ended up being a lot simpler than I was making it, thanks to the PET package directory on the Puppy Official Site.

This is a HOW TO guide on how to get OpenCV up and running in Puppy:

First, we must install many prerequisites to even have the slighest chance at getting this thing to compile. Here are a list of all the packages that I installed before compiling. They can mostly all be downloaded from HERE

NOTE: It should be noted that before you start installing anything but the devx file, that you should verify that you have a recent version of gtk+-2.x (with the dev packages too). There should be some PETs in the same directory that the link above points to.

As noted by swindler, there may be an issue with the gtk+-2.18 PETs, but the gtk+-2.14 PETs work

The pets that are links are not in the folder mentioned above can be downloaded from the link when you click on them.


    devx_xxx.sfs
    Python+=2.6.4-i486.pet
    ffmpeg-20080731-i486.pet
    ffmpeg_DEV-20080731-i486.pet
    zlib-1.2.3.pet
    libjpeg-6b.pet
    libpng-1.2.22-patched1-pup4.pet
    libtiff-3.7.4.pet
    fontconfig-2.6.0-prescott.pet
    fontconfig_DEV-2.6.0-prescott.pet
    x264-20080731-2245-i486.pet
    libv4l



After you have all of those packages installed, you need to get opencv
do that by running:

NOTE: <your_working_dir> indicates the path where you wish to install OpenCV

Code:


#cd ~/<your_working_dir>
#svn co http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk .


After the source code finishes downloading, we can finally start installing. Run the following commands to install:

First, we make a release directory where we will be installing to and cd into that directory.

Code:


#cd ~/<your_working_dir>/opencv
#mkdir release
#cd release


Next, we have to run cmake to configure the build. Followed by the traditional make and make install


NOTE: OpenCV now ONLY supports CMAKE to build. ./configure is no longer used.


Code:


#cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..


If your cmake ouput says the following:

-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - not found


Then we have to modify the CMakeCache.txt file. If it says that those libraries are "found", then skip this step.

First of all, verify that the videodev.h and videodev2.h files exist in the directory: /usr/include/linux

If they don't, then you are likely missing a dependency, that we need to track down for you, before you can continue this install.

If they exist, then you need to open the CMakeCache.txt file from your release folder (should be in the current directory that you ran cmake from)

Search for the lines:
Code:

//Have include linux/videodev.h
HAVE_CAMV4L:INTERNAL=
//Have include linux/videodev2.h
HAVE_CAMV4L2:INTERNAL=


And add a 1 after each equal sign to make it look like this:
Code:

//Have include linux/videodev.h
HAVE_CAMV4L:INTERNAL=1
//Have include linux/videodev2.h
HAVE_CAMV4L2:INTERNAL=1


Save the file and go back to your terminal.

Now run:
Code:

#make
#make install


Now that the source has been compiled and installed, we must make some adjustments to the library path and pkg-config path in order for the libraries to be referenced from any source file on your file system.

Run the following code to add the libraries to the paths:

Code:


#ldconfig -v
#export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
#cd ~/<your_working_dir>/opencv
#export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig



It is a good idea to test the install now.

Run the following code to run the cxcore and cv tests:

Code:


#cd ~/<your_working_dir>/opencv/release/bin
#./cxcoretest
#./cvtest -d ~/<your_working_dir>/opencv/tests/cv/testdata/cv


I had no failures on the cxcore test and a few failures on the cv test due to no data being available. I didn't have the camera working and I think they were testing video. It runs fine regardless.


Finally, it is time to have some fun! A good place to start is with the samples that install with OpenCV. You will need to navigate to the directory

Run the following to build the samples and run an example:

Code:


#cd ~/<your_working_dir>/opencv/samples/c
#. build_all.sh
#./delaunay


Go ahead and try the other samples as well. Some of them are especially neat (some do require a camera).


If you have any questions or suggestions, please let me know. Also if you try it on another version of puppy, also let me know so I can add it to the verified versions.

ENJOY!!

Last edited by jyore on Mon 22 Nov 2010, 02:58; edited 7 times in total
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11121
Location: Arizona USA

PostPosted: Fri 12 Nov 2010, 23:05    Post subject:  

What is Open CV good for? What would I use it for?
Back to top
View user's profile Send private message 
jyore


Joined: 06 Nov 2010
Posts: 43

PostPosted: Sat 13 Nov 2010, 11:30    Post subject:  

OpenCV is an open source computer vision library originally put out by Intel. It is now managed by Willow Garage.

Here is a link to their web page: OpenCV

With computer vision, you can do all kinds of image processing. To list a few:

- Face recognition
- People recognition
- Find a specific letter, shape, image, etc in a larger image or video
- Movement tracking
- Reconstruct a digital version of the real world

How is all of this useful? Well, for instance, I am currently doing research in the field of autonomous construction. We use computer vision to detect all the construction equipment and payloads in the environment. The computer that is doing the computer vision issues commands to the equipment to tell them where to move, how to move, as well as what operation to carry out (pick up a payload, drop a payload, wait for the crane to move a payload, etc).

Hope this gives you a little insight on computer vision and OpenCV. If you have any further questions, feel free to ask.
Back to top
View user's profile Send private message 
jyore


Joined: 06 Nov 2010
Posts: 43

PostPosted: Sat 13 Nov 2010, 20:15    Post subject: Screen Shot  

Here is a screen shot of an example from OpenCV. This particular example uses the find_obj sample.

What it does is takes a certain image and finds all the objects in another image larger image that contains many objects.
OpenCV_FindObject_Demo_screeshot.png
Description  Screenshot from OpenCV's find_obj sample
png

 Download 
Filename  OpenCV_FindObject_Demo_screeshot.png 
Filesize  685.14 KB 
Downloaded  429 Time(s) 
Back to top
View user's profile Send private message 
swindler


Joined: 15 Oct 2009
Posts: 5

PostPosted: Sun 14 Nov 2010, 23:51    Post subject:  

nice work on pulling together all those dependencies. that's been quite a search through the labyrinth.

have you had any luck on getting camera support working? I still can't find a gstreamer that works, and even though I have libv4l-0.5.8.pet installed, cmake can't seem to see it.

any suggestions?
Back to top
View user's profile Send private message 
jyore


Joined: 06 Nov 2010
Posts: 43

PostPosted: Mon 15 Nov 2010, 02:29    Post subject:  

I am currently working on the video camera support on Puppy. I think the problem is in the V4L install. I'm not sure the exact problem, however.

As a sanity check when I was tracking down the dependencies, I did the same proceedures on my Ubuntu machine. Using apt makes tracking down libraries much simpler Smile. On my Ubuntu install, I do indeed have camera support, and I did not include any of the gstreamer stuff. Actually, the OpenCV guides never mention the need for gstreamer as a needed pre-req, just all the ffmpeg libraries.

I was originally going to include the gstreamer stuff, but was getting lots of problems from doing so. After the Ubuntu success without them, I just neglected to care about the gstreamer libraries.

If you do wish to compile with gstreamer, you will need to track down and install at least the following libraries:


    gstreamer
    gstreamer plugins base
    gstreamer plugins good
    gstreamer plugins bad
    gstreamer plugins ugly
    gstreamer plugins dev


The only problem in finding those that I had was the dev package. I don't remember seeing the source code on the gstreamer site. This happens to be the package that has the gstreamer-app and gstreamer-video libraries. Without these, cmake will always configure gstreamer as off. I did find the dev package in Ubuntu once before, using apt I beleive...

Looking back over the differences between my Ubuntu install and my Puppy install, it seems that the main difference between the cmake outputs is on the v4l/v4l2 list item.

On Ubuntu I get: V4L/V4L2: 1/1
On Puppy I get: V4L/V4L2: /

This seems to support my theory in that the V4L stuff wasn't done correctly. Maybe the cmake didn't actually find the v4l library...I may try to download the source and compile it myself to see if there is a difference or if something missing...It is possible that both libraries may be needed as well (V4L and V4L2).

I have attached a screen shot from my Ubuntu install showing a working camera program, as well as the cmake output from Ubuntu.

I will be working on the camera stuff off and on throughout the day, so I will make note of any progress or problems to this forum page. If you get anything going or have any ideas, please let me know so I can add it.
ubuntu_opencv_cmake_report.txt.tar.gz
Description  This archive includes 2 items:

- screen shot from motion tracking on my Ubuntu install
- cmake output from my Ubuntu Install

It should be noticed that the only considerable difference between this cmake report and the one from both my puppy installs i
gz

 Download 
Filename  ubuntu_opencv_cmake_report.txt.tar.gz 
Filesize  47.54 KB 
Downloaded  380 Time(s) 
Back to top
View user's profile Send private message 
jyore


Joined: 06 Nov 2010
Posts: 43

PostPosted: Mon 15 Nov 2010, 13:06    Post subject:  

Update on the video stuff...

I believe the problem is indeed related to V4L/videodev/camera drivers, where:

V4L: video for linux libraries
videodev: video development library module
drivers: I have been trying to use the uvc drivers

What I have found is that I can get a videofeed when I run ucview. However, when I try to use xawtv or other programs/methods (including OpenCV), there is a failure to grab images from the camera.

The errors are all IOCTL errors.


I am pretty sure that the OpenCV library isn't opening the video feed because of the same IOCTL errors. The curious part is that when Cmale runs to configure the install, it does not detect the videodev.h/videodev2.h, even though they are present at the directory where Cmake is looking. My guess is that there are some hidden dependencies that OpenCV needs in addition to just the library.

I am looking more into this now.

Btw, I have added a couple more libraries, and it is recognizing that I have V4L, but not V4L2. The camera I have might be a V4L2 device, which could be the real issue. I am going to be looking for every possible library that deals with the V4L and install them and see where I get. I will make PETs of each of these libraries so that it will be easier to replicate later.
Back to top
View user's profile Send private message 
jyore


Joined: 06 Nov 2010
Posts: 43

PostPosted: Mon 15 Nov 2010, 22:57    Post subject:  

AND I GOT IT!!!!

So, I was looking in the cmake output and noticed that there were the lines:

-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - not found


When in my Ubuntu Install, they were found...hints why I was wondering about the videodev stuff in the first place.

I tracked went to the appropriate directory, and there they were...seems odd that they exist in the correct directory, ucview uses them, cmake reported them missing, and opencv had no video support...certainly odd. But, the videodev libraries do exist, so I figured, let's get hacking.

After running cmake with the appropriate switches, there is a CMakeCache.txt file that is generated. This file has all the switches for what cmake found and didn't find, which is then used in the make/make install process. I went to the lines regarding the videodev files and modified them as shown below:

Was:
Code:

//Have include linux/videodev.h
HAVE_CAMV4L:INTERNAL=
//Have include linux/videodev2.h
HAVE_CAMV4L2:INTERNAL=


Changed to:
Code:

//Have include linux/videodev.h
HAVE_CAMV4L:INTERNAL=1
//Have include linux/videodev2.h
HAVE_CAMV4L2:INTERNAL=1


This basically tells the install scripts that those really do exist and to go ahead and to build the support.

After I installed, I built the samples that use a video camera, and they worked!!!!

I did, however, install a few libraries in the process, so I will add those as optional/unknown dependency in the tutorial (first post). I don't really think that any of them made a difference, so it would be nice if someone could verify. I will also add the CMakeCache hack into the tutorial as well.

Enjoy, and here is a screen shot of opencv's motion tracking sample working in puppy. (screen shot from same program as the Ubuntu post)
puppy_opencv_motion_track_sample.png
Description  OpenCV's motion tracking sample program running in puppy
png

 Download 
Filename  puppy_opencv_motion_track_sample.png 
Filesize  384.83 KB 
Downloaded  409 Time(s) 
Back to top
View user's profile Send private message 
swindler


Joined: 15 Oct 2009
Posts: 5

PostPosted: Fri 19 Nov 2010, 20:05    Post subject:    

after much monkeying around, (copying libs, trying various pets, etc.), I think I almost had it working but something made puppy freeze up on me. So I'm starting over with a fresh frugal install of 431, gonna flesh out this howto.

using all the pets above, with the CMakeCache.txt edits, 'make' stops at:

Code:

[89%] Building CXX object apps/haartraining/CMakeFiles/createsamples.dir/createsamples
Linking CXX executable ../../bin/opencv_createsamples
/usr/lib/gcc/i486-t2-linux-gnu/4.2.2/../../../libgtk-x11-2.0.so:undefined reference to 'g_array_get_element_size'
/usr/lib/gcc/i486-t2-linux-gnu/4.2.2/../../../libgtk-x11-2.0.so:undefined reference to 'g_array_unref'
/usr/lib/gcc/i486-t2-linux-gnu/4.2.2/../../../libgtk-x11-2.0.so:undefined reference to 'g_mapped_file_unref'
collect2: ld returned 1 exit status
make[2]: *** [bin/opencv_createsamples] Error 1
make[1]: *** [apps/haartraining/CMakeFiles/createsamples.dir/all] Error 2
make: *** [all] Error 2



my guesses are:
1) there's some dependency we don't have yet (or it's the wrong version?)
2) something's in the wrong place (or hasn't gotten linked properly)

think you can track this down before I do? Wink
Back to top
View user's profile Send private message 
swindler


Joined: 15 Oct 2009
Posts: 5

PostPosted: Sat 20 Nov 2010, 18:36    Post subject:  

well, that was easier than I thought. The problem was with gtk+-2.18 and its DEV package. don't know what the problem was, but
opencv compiled right up when I switched them for:

gtk+-2.14.7-1-p4.pet
and
gtk+_DEV-2.14.7-1-p4.pet


(from that page of pets in the first post)
I'll also confirm that the edits to CMakeCache.txt lets opencv read from my webcam. so ... well done, jyore.

now to learn how to use this thing. Very Happy
Back to top
View user's profile Send private message 
jyore


Joined: 06 Nov 2010
Posts: 43

PostPosted: Mon 22 Nov 2010, 02:51    Post subject:  

Thanks for testing everything out. I added your notes on the gtk packages into the original post so that others can see it. Also, I added you to the verifications section.

Thanks again for helping with the verification. Let me know if you come across any problems.

A good place to start learning is to find some of the sample programs and go through them and pick out the useful bits for your application.

Enjoy Smile
Back to top
View user's profile Send private message 
astha.aggarwal

Joined: 26 Nov 2010
Posts: 1

PostPosted: Fri 26 Nov 2010, 03:06    Post subject: Not able to use cross compiled OpenCV with all webcam device  

Hi,

I cross compiled the OpenCV library with arm-linux-gnueabi. and its working fine with microsoft webcam. But its giving error with T-Link webcam.
Error is "HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV Unable to stop the stream.: Bad file descriptor"

What can be the reson? Or i did some mistake while cross compiling the lib and need to do some changes in CMakeCache.cmake file?and how to rectify it?

I disabled the ffmpeg as i need to capture the image only not the videos.
//Include FFMPEG support
WITH_FFMPEG:BOOL=OFF
Back to top
View user's profile Send private message 
jyore


Joined: 06 Nov 2010
Posts: 43

PostPosted: Tue 30 Nov 2010, 17:17    Post subject:  

astha.aggarwal...which version of Puppy are you using? If you are not using Puppy, then I will still try to answer your question, even though this forum is specifically for Puppy Linux users...

I personally have not seen the error you are getting, but it seems to be some incompatibility with the V4L2 drivers and that specific camera. Do you know what drivers the camera that does not work uses on Linux systems? The Microsoft cams use the UVC drivers, which I know work with OpenCV and Linux. Also, does that camera work with other applications like ucview, mplayer, any vlc application, skype, etc?

I do not think it is the OpenCV install since it worked with the one camera.[/quote]
Back to top
View user's profile Send private message 
cannot

Joined: 03 May 2012
Posts: 2

PostPosted: Thu 03 May 2012, 11:15    Post subject:  

Hi! Thanks for the detailed description!! Very handy...

I'm going to install opencv on puppy, do you think your process will work smoothly on puppy 528?

ciao,
pedro
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [14 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1110s ][ Queries: 13 (0.0049s) ][ GZIP on ]