OPENCV 3.0.0 AND JAVACV1.1 BUILT AND WORKY ON RASPBERRY 2 !

It should be one click worky with latest mrl version : http://mrl-bucket-01.s3.amazonaws.com/myrobotlab.jar

GOT 8 fps with oracle java 8 and only 1 fps with openjdk .....

Alessandruino

8 years 4 months ago

Here is some dependencies you may need to install :

  • sudo apt-get update
  • sudo apt-get install build-essential cmake pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3
  • sudo apt-get install libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4-dev
  • sudo apt-get install libtiff4 libtiffxx0c2 libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev
  • sudo apt-get install libavcodec54 libavformat54 ibavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
  • sudo apt-get install libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils
  • sudo apt-get install swig libv4l-0 libv4l-dev
  • sudo apt-get install libpng-dev libjpeg-dev libxxf86vm1 libxxf86vm-dev libxi-dev libxrandr-dev
  • sudo apt-get install mesa-common-dev
  • sudo apt-get install mesa-utils-extra libgl1-mesa-dev libglapi-mesa
  • sudo apt-get install libgles2-mesa-dev
  • sudo apt-get install freeglut3 freeglut3-dbg freeglut3-dev libmgl-glut5
  • sudo apt-get install libxmu-dev libxi-dev
  • sudo apt-get install libudev-dev

Thanks Alessandruino.

I now get 6 fps unfiltered at 640*480 and 15 fps filtered with PyramidDown.

Don't bother about the picture beeing upside down. That can be easy fixed.

As a comparision I get 7-8 fps in both cases with my builtin laptop camera .....

 

For the Raspberry PI camera to work the /etc/module file needs an extra line to load the latest camera drivers.

sudo vi /etc/modules

add this line at the end of the file

bcm2835-v4l2

save

reboot

 

I also got several messages during the installation of the dependencies. Some modules were not found, some needed a later versions some were already installed and so on. I will try to figure out what dependencies are necessary. I found a very good guide on the dependencies for OpenCV here:

http://www.pyimagesearch.com/2015/10/26/how-to-install-opencv-3-on-rasp…

I think step #1 should install all necessary dependencies for OpenCV.

It also installs development tools. So I think some of the installations are only necessary if you want to compile OpenCV, not for using it in MRL.

The rest should be dependencies for the link between MRL and OpenCV i guess.

btw kwatters told me to also install:

apt-get install libunicap2

 

I continued testing many of the fiters, and most work. However some thow an error. Most important for me, the FaceDetect. This is the error that I get:

 java.lang.RuntimeException: /home/pi/javacpp-presets/opencv/cppbuild/linux-arm/opencv-3.0.0/modules/core/src/persistence.cpp:4976: error: (-2) The node does not represent a user object (unknown type?) in function cvRead

 
at org.bytedeco.javacpp.opencv_core.cvLoad(Native Method)
at org.myrobotlab.opencv.OpenCVFilterFaceDetect.imageChanged(OpenCVFilterFaceDetect.java:154)
at org.myrobotlab.opencv.OpenCVFilter.preProcess(OpenCVFilter.java:109)
at org.myrobotlab.opencv.VideoProcessor.run(VideoProcessor.java:459)
at java.lang.Thread.run(Thread.java:744)
 
 

Yes.

Facedetect works now. 2 fps and about 2 s latency. CPU at more than 50%.

Hmmm... remote desktop may steal some CPU. Testing connecting a monitor to the PI.

Same test now with HDMI: facedetect 6 fps, still the same latency.

 

I have tried following this tutorial but it now seems a bit out of data or does not work exactly the same on the new version of Raspbian on the Pi 3.  I have update the list below when the versions listed here were out of date.  The bigger issue was that ffmpeg does not seem to be available.  

I am not sure if anyone else has tried this recently but in Red is the error messages I got when trying to follow Alessandruino'

s list of dependencies:
  • sudo apt-get update
  • sudo apt-get install build-essential cmake pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3
  • sudo apt-get install libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff5-dev
  • sudo apt-get install libtiff4 libtiffxx0c2 libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev
  • pi@raspberrypi:~ $ sudo apt-get install libtiff4 libtiffxx0c2 libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Package ffmpeg is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
     
    E: Package 'ffmpeg' has no installation candidate
     
  • sudo apt-get install libavcodec54 libavformat54 ibavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
  • pi@raspberrypi:~ $ sudo apt-get install libavcodec54 libavformat54 ibavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    E: Unable to locate package libavcodec54
    E: Unable to locate package libavformat54
    E: Unable to locate package ibavcodec53
    E: Unable to locate package libavformat53
     
  • sudo apt-get install libxine1-ffmpeg libxine2-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils
  • pi@raspberrypi:~ $ sudo apt-get install libxine1-ffmpeg libxine2-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    E: Unable to locate package libxine1-ffmpeg
    E: Unable to locate package libxine1-bin
     
  • sudo apt-get install freeglut3 freeglut3-dbg freeglut3-dev libmgl-glut7.2.0

I'm not sure if you need ffmepg to use OpenCV on the PI. But I compiled it using this guide:

https://support.ustream.tv/hc/en-us/articles/207852457-Raspberry-Pi-Str…

But please test first if it works without ffmpeg

And make sure that the v4l2 drivers are active ( makes the Raspi camera show up as /dev/video0 ) like a USB camera

You do that by adding a line:

bcm2835-v4l2

in /etc/modules

for example by using:

sudo vi /etc/modules

or any other popular editor :)

Hey Kyle

i got OpenCV 3.1.0 compiled today

I'm running on a Pi with the latest Jessie build and the latest MRL build loaded

I have the Pi camera generating video in the MRL OpenCV video widget using the MRL OpenCV filter test script OpenCV.py

i'll write up the exact steps and share it here

Ya .. weird, but OpenCV face detect works only with 2.4.10 xml data (fixed in repo) ...

But 16 fps from 90 fps !!!   ARRGHH !! ..  

Did you got 90fps on raspi modules - and now get 16 fps on raspi ???

raspivid can deliver 90 fps. However I can't replay 90 fps in any player I have. The 90 fps can bee seen if the H264 datastream is saved to a file and the replayed at a lower fps. Like in this video. ( not created by me ).

https://www.youtube.com/watch?v=gXqpzmPq6SY

The camera needs to be told what mode it should use. Mode 7 is the fastest, 90 fps @ 640*480.

https://www.raspberrypi.org/documentation/raspbian/applications/camera…

How does OpenCV tell the camera what mode it should use ? In raspivid, fps will override any other setting. The camera will decrease the resolution to the best resolution it can deliver at a specified fps.

Can v412-ctl be used in some way ?

v4l2-ctl -p 90
 v4l2-ctl -v width=640,height=480,pixelformat=H264
 v4l2-ctl --stream-mmap=3 --stream-count=900 --stream-to=test90fps.h264