OpenCV as a web service - c++

i am looking into facial recognitions using Local Binary Pattern Histogram have came across OpenCV. Within OpenCV, the Local Binary Pattern Histogram has a function which compares histograms "compareHist". How can i perform this function on a web server?. Is it possible to run OpenCV on a web server? (i am thinking about writing the whole function myself however it is based on multiple custom created classes and its rather troublesome - what language should i use? - this would be my last resort).

OpenCV comes with cv::FaceRecognizer, which includes Eigenfaces, Fisherfaces and Local Binary Patterns Histograms. It comes with a very detailed documentation, please see:
http://docs.opencv.org/trunk/modules/contrib/doc/facerec/index.html
No need to implement it yourself. If you want to do this in another language, then you can easily look up the implementation in the contrib module of OpenCV. I am sure you can get some impression there.
As for the webserver. If you have a real server, then sure you could put OpenCV up there and interface with it. If you want to get something going real quick, have a look at the OpenCV Python bindings for cv::FaceRecognizer. I did a post on the OpenCV QA page just yesterday:
http://answers.opencv.org/question/253/broken-python-bindings-with/?answer=255#post-id-255
However, it's a bit complicated due to an error on my side. There was a bug in the official OpenCV 2.4.2 release, so for the Python bindings to work you'll need the trunk version. Note, that the source code is now hosted with git, so you can get it with:
git clone git://code.opencv.org/opencv.git
for example. Then if you are in Linux, you can follow this tutorial on how to install OpenCV:
http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html
or if you are in Windows, then:
http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html
might help. Make sure you have python-dev and python-numpy installed, so the Python bindings are compiled. If you are in Windows, simply install Python2.7 and NumPy (http://www.numpy.org).
You might be interested in my Guide to Face Recognition with Python also, which is available at:
https://github.com/bytefish/facerecognition_guide
That shows a really lightweight implementation of two algorithms.

Disclaimer I am a founder.
Algorithmia provides OpenCV as a service through our API.
http://algorithmia.com/users/opencv

Related

How can I control and receive video stream from SITL drone using px4,gazebo and C++ without using ROS?

I want to program a drone to fly with a C++ project using image processing analysis in real-time (using OpenCV). I want to do it with PX4, Gazebo simulator. The final goal is to run the project on a real
drone using Jetson-Nano and Pixhawk drone.
I have 2 main problems.
I can't manage to get the video stream of the px4 drone models without using ROS. I have followed this official guide to install the relevant software (Gazebo, Px4, GCS).
For python we have Drone-kit library to control the drone, but I want to use C++ for my project. what are the alternatives tools instead of the Drone-kit to control drones with C++ and how I can receive the video stream from the gazebo px4 drone?
After that I tried to search for information online for hours and go through the documentations, I could not find a suitable guide or solution.
thanks.
Posting this as an answer after details in the comments made things more clear.
For an application like this ROS should most definitely be used. It comes with a wide range of pre-built packages and tools to enable easy localization and navigation. When looking at UAVs the MoveIt! package is a good place to look. It handles 3D navigation and has a few UAV implementations already. The Hector Quadcopter package is another good option for something like SLAM.

How to use the C++ functions of OpenCV from Python?

I'm using the Python bindings of OpenCV and it's really great. However, there are functions in the C++ version that are missing from the Python bindings, BackgroundSubstractorMOG2, and a lots of feature detection algorithms for example. What would be the easiest way to call them from Python?
I hope this helps people looking for a fast and easy way.
Here is the github repo with the open C++ code I wrote for exposing code using OpenCV's Mat class with as little pain as possible. It was originally inspired by Yati Sagade's example.
[Update] This code now works for OpenCV 2.X and OpenCV 3.X. CMake and experimental support for Python 3.X are now also available.
I also found that a few months after my original utility was written, Sudeep Pillai also wrote a similar thing for C++/CMake. There seems to be OpenCV 2 and OpenCV 3 support as well. May be worth a try.
Have a look to SimpleCV. It Python base and it a warping OpenCV. Maybe you can found something there.

OpenCv and Ruby on Rails

Can I use OpenCV with Ruby on Rails? If so, how can I do that? Or, what resources do you recommend for that?
Thanks.
There is also an open CV gem, fwiw -- https://github.com/ruby-opencv/ruby-opencv.
Sure you can!
It just depends on what do you need as there is no "one" silver bullet.
If you want to create an online home surveillance, for example, then you would probably have least effort by writing:
C++ image-processing command-line application on top of OpenCV that would write the surveillance events and/or images to SQLite database.
Read the database directly from Rails.
For anything more complex, you'd need a more complex architecture.
Whatever you do, pick the best tools for the purpose:
Let OpenCV do what it is best at (image processing)
Let Rails to it's magic (simple, less demanding online access to some resources)
In order to link OpenCV and Ruby together, you could create a dedicated Ruby-to-C++ bridge because none of the existing ones can match diverse needs and most frameworks will do for a few specialized (i.e. designed by you) function-calls through your bridge.
This link would be a good start to pick a framework for a bridge - just go for one and see what comes out.
You could write a program using OpenCV in C++, and then just process your data with it, by using CGI (Common Gateway Interface http://en.wikipedia.org/wiki/Common_Gateway_Interface). I don't think you can bind native code to Ruby like you can do in Java (JNI)

Rendering using OpenSG python bindings

Hey!! I'm looking for python bindings for opensg 1.8.. I haven't been able to find it. I have read somethin about pyopengs. Is it still available? I am working on linux platform (ubuntu). If anyone could direct me to it I would be grateful.
The homepage and source code is on google code: pyOpenSG Project
As one of the creators of pyOpenSG, I can tell you that it is definitely still alive and kicking. We use it in production software all the time. It has become so stable for us though that we don't often update the code base. The python binding generator that we use (py++) just keeps everything working between revisions.

Is there an easy way to provide a Matlab-based Web App or Web Service?

A colleague and I have spent a few years developing a really cool Matlab application, MDLcompress. Within Matlab, I can type "MDLcompress('filename.txt')" and it will tell me all sorts of really cool stuff about the contents of filename.txt. We'd like to allow other people to use MDLcompress without downloading the code, installing Matlab, etc. Ideally, we'd have a simple web page where they selected a file from their machine, it got uploaded to my workstation (which is already running tomcat for other purposes, if that makes things easier), kicked off a process along the lines of "matlab < MDLcompress.m filename.txt > results.txt" and then displayed results.txt in their browser or showed a link to let them download it.
Trouble is, my Matlab skills far exceed my web skills. Google has 100 generic tutorials, but nothing as simple as I want, at least not specific to Matlab.
Thanks in advance
If you are mostly proficient in MATLAB you can write web application in MATLAB with MATLAB Web Server
Edit:
Matlab Web Server is discontinued, so it is not for you if you use recent version of Matlab. May be this tutorial will help to create CGI module from Matlab code.
A possible way is to compile the matlab code into C,
and then make the C file into an apache module, and use an apache server.
I have no idea how complicated this is, but it may work.
Based on the tags, I assume you're trying to deploy to Tomcat or similar. The most straightforward way to do this is to use MATLAB Builder JA to create a Java wrapper for your code, then use the standard tools to deploy the Java as a web service.
If you can afford to lose some of Matlab's more powerful proprietary features, there are several open-source numerical computation engines that use syntax mostly compatible with that of Matlab. One of the most mature of these is GNU Octave.
There are several examples of online Octave interfaces. Octave Online is a new interface that supports a live prompt and an online editor. I am a member of the team developing Octave Online. You can find more examples of online Octave interfaces on the Octave wiki. The Octave mailing list is a good resource for prior online Octave projects.
We have developed a toolbox called Modelit Webserver Toolbox that should allow you to do this. We use this ourselves to run a Routing algorithm implemented in Matlab for an online route planner (the link is on our website). You can use the toolbox in conjunction with Tomcat and Matlab (2006b and up) or a compiled Matlab executable. The toolbox also provides a mechanism to run several jobs in parallel.