Trying to create a HOG implementation for detecting people - c++

I would like to create results similar to the video found at this link. I tried the Object Detection and Localization toolkit made for the work done by Dalal and Triggs found here, and I tried trainHOG(https://github.com/DaHoC/trainHOG), a program that uses OpenCV that can be trained to detect people.
For the ODL toolkit, I had problems compiling because its requirements are now dated. The Ubuntu packages that provide the requirements for ODL (ImLib, Boost, and Blitz) are not compatible with the versions of the packages required by ODL. I actually went through a lot of effort building older versions of the required packages but hit a dead end of an error saying:
error: no matching function for call to ‘boost::program_options::validation_error::validation_error(std::basic_string)’ + argument.desc.find(*ai, false).format_name());
For trainHOG I was able to detect people but only if they were very small in the image. I also got a lot of false positives. I trained it with 1133 positive images and ~8500 negative image, all of which were 64x128 in size.

OpenCV has a API for HOG Descriptor which you can use easily.
However, HOG is very very simple to implement and it should take whole deal of time for you to implement. You can refer to this tutorial which I found to be very helpful when for understanding HOG.
If you still find problem than let me know so I can help you code it.

Related

Image detection with C++ using opencv

So I have been assigned a project on quite short notice, and given that I have a very small amount of experience with c++ I thought it would be a good idea to ask for some help from the community!
Basically, we have a .png which is an image of a baseball game, and we must use opencv (and its likes) to detect, outline and extract coordinates of the bat, using c++.
So far I have installed opencv onto visual studio 2019 and read through hours and hours of tutorials but feel like I have not made a huge amount of practical progress.
As a beginner, I'm wondering if there is anyone here who could make the path forward a bit more clear for me!
Template machine is one of the easy solutions, below is an example for template matching from open cv -
https://github.com/opencv/opencv/blob/master/samples/cpp/matchmethod_orb_akaze_brisk.cpp
You can do this with many other python library's -
https://scikit-image.org/docs/dev/auto_examples/features_detection/plot_template.html#sphx-glr-download-auto-examples-features-detection-plot-template-py
This will not solve object detection problems in general but will be able to find an object of your interest in many cases, this is one of the quick solutions that I can think of.

OpenCV training output

So I am creating my own classifiers using the OpenCV Machine Learning module for age estimation. I can train my classifiers but the training takes a long time so I would like to see some output (status classifier, iterations done etc.). Is this possible? I'm using ml::Boost, ml::LogisticalRegression and ml::RTrees all inheriting cv::StatModel. Just to be clear i'm not using the given application for recognizing objects in images (opencv_createsamples and opencv_traincascade). The documentation is very limited so it's very hard to find something in it.
Thanks
Looks like there's an open feature request for a "progress bar" to provide some rudimentary feedback... See https://github.com/Itseez/opencv/issues/4881. Personally, I gave up on using the OpenCV ML a while back. There are several high-quality tools available to build machine learning models. I've personally used Google's Tensorflow, but I've heard good things about Theano and Caffe as well.

OpenCV where is tracking.hpp

I want to use an OpenCV's implementation of the TLD tracker. Internet says that I have to include this file: opencv2/tracking.hpp (e.g. see https://github.com/Itseez/opencv_contrib/blob/master/modules/tracking/samples/tracker.cpp).
But there is no such a file.
Well, what must I do to use TrackerTLD in my C++ project?
(OpenCV 3.0.0 beta for Windows, installed from the .exe package from opencv.org)
As Floyd mentioned, to use TrackerTLD, you need to download OpenCV contrib repo. Instruction is in the link, so explaining it shouldn't be necessary.
However in my opinion using TrackerTLD from OpenCV repo is bad option - i've tested it (about a week or 2 ago) and it was terribly slow. If you are thinking about real time image processing, consider using other implementation of TLD or some other tracker. Right now i'm using this implementation and it's working really well. Note that tracking an object is quite a time consuming task so to perform a real time tracking i have to downscale every frame from 640x480 to 320x240 (Propably it would work well (and definitely faster) in even lower resolution). On the web page of author of this implementation you may find some informations about TLD algorithm (and implementation) and another tracker created by this author - CMT(Consensus-based Matching and Tracking of Keypoints). Unfortunetely i haven't test it yet so i can't tell anything about it.

Implementation help on database video matching in OpenCV

I'm trying to develop a program to match query videos to videos in a database. So something like google image search but for videoclips. I'm using OpenCV for this implementation.
I can succesfully generate feature descriptors for selected frames in de video (which tbh isn't that hard).
I have no clue how I should implement the database part. I was wondering if somebody could give me pointers to what already exists in OpenCV to ease my implementation: What classes to extend, how to structure it, any existing implementations/examples,...?
Basically I would have a set of descriptors from a query clip which I want to compare to a (large) database of precomputed descriptors, and then have some voting algorithm to return a best match.
So i'm not asking for which algorithms to use, I just want to know about the best practices in OpenCV to implement such a thing i'm describing.
I am using OpenCV 2.4.8 C++ on a Mac in Xcode, if that somehow matters
EDIT
Let me make my question a little bit more specific.
If I use SIFT of SURF detector/descriptor I get a lot of features. Doing this for a bunch of frames of a bunch of videos will result a lot of data.
If I use FlannMatcher (or something in the likes) I have to have everything in memory... but this seems very unreasonable... So somehow there should be a way to implement this using a database. So I'm looking for any hints on how to do this, what kind of database to use...
thanks
You may cluster the features into fewer classes, and store/search class id before comparing actual features

OpenCV as a web service

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