Can onion omega support opencv?
Been looking at this:
and figure that we may be able to cross-compile this. Here is a reqs list for what needs to be on the host machine, so far as I have seen from the above links:
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
and then, you'd have to do something like:
git clone https://github.com/Itseez/opencv.git cd ~/opencv mkdir build cd build cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
on the host machine. Not sure if any of this would work, but I am unable to do anything at work but summarize what would be my initial foray into getting this done.
After it is built (if it can be), I'd then try to compile the node-opencv package from npm, and run this all from the web front end. . .
Anyone know if this is already offered in the wide world of other OpenWRT based routers? Probably not, as most routers don't have cameras :P
@Theodore-Borromeo This might be a good starting point. https://github.com/WRTnode/openwrt-packages/tree/master/libs/opencv
@Boken-Lin Since this is in your open wrt packages directory, does this mean you all are already starting on this? Or is this to try and bait me into compiling this ;) ?
@Theodore-Borromeo We started on it but unfortunately none of us here at Onion had any experience with OpenCV, so we are still working through tutorials and documentation to learn how to use it. It would be super special awesome if you can help us compile it :D
@Boken-Lin OK. More notes:
Someone got it working on a MIPS processor, though the MIPS processor was strong enough to compile on device, here: https://mipsci20.wordpress.com/2015/01/26/installing-opencv-on-ci20/ (Used it for a book reading assistant that responded to gestures for highlighting and stuff. Interesting compile flags of note at step 4 with some configuration stuff as well on device. Will need to adapt to cross-compile with on-device tinkering)
Also a guide for compiling for the WR703N using OpenWRT toolchain here: http://mark4h.blogspot.com/2013/04/cross-compiling-opencv-for-openwrt.html
(I'll need to install a way to forward a gui though, as per something like: http://stackoverflow.com/questions/16296753/can-you-run-gui-apps-in-a-docker-container if i insist on my docker contained toolchain )
Stuck trying to get my ps2eye cam working before I can bother trying to compile and run openCV (with no webcam working, I don't have an input device )
https://cmake.org/runningcmake/ has info for manually running cmake from a terminal. Once I get a cache file built, it could be rolled into a docker container setup. Trying this route now. . .
@Theodore-Borromeo Were you able to sort out the webcam not being recognized? My PS2 Eye hasn't arrived yet.
@Boken-Lin I could get neither to work. They'd both show plugged in, but no /dev/video* would enumerate. I think it's due to a version mismatch between the kernel on the most recent firmware and the drivers provided by barrier breaker/chaos calmer/etc. They probably should work with any kernel, though I think there is some hardcoded kernel value baked into both drivers preventing it from running. That, or some dependent package has been deprecated between the versions that the drivers did work on, and the one we have now :(
@Boken-Lin Also, I get to 26% on my cross-compilation, and then get this:
/node/opencv-2.4.11/modules/highgui/src/cap_xine.cpp:58:18: fatal error: xine.h: No such file or directory compilation terminated. make: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_xine.cpp.o] Error 1 make: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 make: *** [all] Error 2
Still trying to find the package responsible for providing that thing on whatever version of ubuntu I ended up using in borromeotlhs/docker-onion-omega-nodejs:v1 (which I'm now utilizing as it had a working cross-compilation toolchain ) :P
@Theodore-Borromeo Yeah, As soon as our PS2 eye arrives I will give it a try to see what the issue is... It really doesn't make sense because it works with a few other webcams I've tried out. Perhaps the driver required for the eyes are not installed. Anyways, we'll play around with that and see if anything can be done.
Good luck with compiling OpenCV! I know there are a few people who are interested in using it in their projects.
@Boken-Lin OK, so I've gotten up to ~25% in the compilation phase. I am missing some stuff, so I need some help finding out which packages provide (and how I have to make it visible to the openWRT toolchain) the following report for found and missing header files/libs/apps on my cross-compile ubuntu dev container:
stuff that is found:
-- checking for module 'gtk+-2.0'
-- found gtk+-2.0, version 2.24.23
-- checking for module 'gthread-2.0'
-- found gthread-2.0, version 2.40.2
-- checking for module 'gstreamer-base-0.10'
-- found gstreamer-base-0.10, version 0.10.36
-- checking for module 'gstreamer-video-0.10'
-- found gstreamer-video-0.10, version 0.10.36
-- checking for module 'gstreamer-app-0.10'
-- found gstreamer-app-0.10, version 0.10.36
-- checking for module 'gstreamer-riff-0.10'
-- found gstreamer-riff-0.10, version 0.10.36
-- checking for module 'gstreamer-pbutils-0.10'
-- found gstreamer-pbutils-0.10, version 0.10.36
-- checking for module 'libunicap'
-- found libunicap, version 0.9.12
-- checking for module 'libdc1394-2'
-- found libdc1394-2, version 2.2.1
-- checking for module 'libv4l1'
-- found libv4l1, version 1.0.1
-- checking for module 'libv4l2'
-- found libv4l2, version 1.0.1
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- checking for module 'libavcodec'
-- found libavcodec, version 54.35.0
-- checking for module 'libavformat'
-- found libavformat, version 54.20.4
-- checking for module 'libavutil'
-- found libavutil, version 52.3.0
-- checking for module 'libswscale'
-- found libswscale, version 2.1.1
Things the toolchain can't find:
-- checking for module 'gstreamer-base-1.0'
-- package 'gstreamer-base-1.0' not found
-- checking for module 'gstreamer-video-1.0'
-- package 'gstreamer-video-1.0' not found
-- checking for module 'gstreamer-app-1.0'
-- package 'gstreamer-app-1.0' not found
-- checking for module 'gstreamer-riff-1.0'
-- package 'gstreamer-riff-1.0' not found
-- checking for module 'gstreamer-pbutils-1.0'
-- package 'gstreamer-pbutils-1.0' not found
-- checking for module 'libucil'
-- package 'libucil' not found
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - not found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.6", minimum required is "2.0")
I know that this is not found, but I also know how to fix once I get it compiled W/O python for now:
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is at least version "2.7")
-- Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)
-- If you want to enable Python/Numpy support, set the following variables:
Any clues as to the packages available on latest LTS ubuntu that provide these would probably greatly speed up my successful compilation, as I've clearly got the right toolchain and makefiles, just missing specific bits and pieces :(
@Theodore-Borromeo Seems like you are just missing the header files. Did you install
<package name>-devpackages with
apt-get? These are the packages that's supposed to provide the header files that you will need to do cross-compilation.
@Boken-Lin I did, one of the issues was that I had to symlink videodev.h to videodev2.h. Besides that, it seems that there would need to be a lot more research to enable a lot of the errors emanating from highgui at this point. What I'm trying now is to just compile opencv with none of the gtk/qt stuff, and only enable ffmpeg. That should be barebones enough as a proof of concept. I could then add in python support, maybe (C examples are in there now).
But yeah, apparently a lot of stuff happened in 14.04 that caused a lot of incompatibilities for opencv. I may have to downgrade to 12.02 for the docker-onion-omega-nodejs image, such that when I then extend from it, I can easily utilize the cross compile toolchain + have a stronger guarantee that packages like ffmpeg won't have been deprecated in favor or libav and other such annoyances.
@Boken-Lin Seems that I can't get my cross compile build toolchain to 'see' some dev files, libs and headers. Just spent the last week figuring out how to forward the x11 server from a container onto a host machine just to utilize cmake gui! Now that I got that up for an easier way to create the necessary cmake build files, I'm failing sooner in the build process! :(
I think I may need to install the necessary dev headers and such then compile the open wrt toolchain. Have you ever seen a need to do that in your experience? I had thought that seeing PATH variables and such would be all that's needed, but I guess it makes sense that a cross compiler would need to know about headers before being compiled to then go on and cross compile, right?
@Theodore-Borromeo Hmmm, that's a good question. I'm not sure what the answer for that is. So you are saying that even after installing all the
devpackages, the compiling environment is unable to locate the header files?
Can you give me a list of libraries/packages you've installed? I can try to create a SDK after installing them. You can give that SDK a try to compile
Seems there is a bunch of already compiled binaries for opencv per the blog post @ http://mark4h.blogspot.com/2013/04/cross-compiling-opencv-for-openwrt.html
And then, there are folks who give a tutorial for making a simple app on mac os x, that would probably be similar using the cross-compile toolchain, @ http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/
@Theodore-Borromeo Nice! Thanks for sharing :) Let's see what we can build with OpenCV.
Brief update, I was able to get a cmake build going, and built the opencv libs for the host system. That was all good, however, once I tried to do cross-compilation, I got the same "missing headers" nonsense.
Since it's been so long since I've taken a shot at this, it actually helped as I think I've found some possible solutions as per:
Of course, that solution may only be for a HOST (which I already have working @ v2.4.9 )
I may have to bite the bullet and just start all over again with the latest opencv just to see if they've moved passed it. However, MIPS cross compilation is a definite niche subject with only those folks doing things on OpenWRT even caring to explore this architecture! Still, OpenWRT is still pretty straightforward. I wonder if this could be made a feed if it compiles successfully?
This was built using the makefile from @Boken-Lin's original suggestion ( https://github.com/WRTnode/openwrt-packages/tree/master/libs/opencv ). I have yet to flash it and test it out, but I figured this being in here sooner rather than later would be good.
The next step, should npm be working, would be to get the nodejs opencv packages for opencv3.0 working, and then tying them into a web camera stream, right?