OpenCV cascade classifier from Python - python

I am working on a computer vision/machine learning problem in python and have so far not needed opencv. However, I now need to use a fast cascade classifier to detect objects in a set of images. I came across the Haar based classifier written in C++. The testing phase can be called from Python, but I cannot find a way to train the classifier to recognize other objects from Python (I was only able to find this, which uses C++).
Is the training functionality of the Haar cascade only available through C++ or can it be used with Python?
If only C++, any pointers on what I need to install to get started?
Thanks!

Related

Training Yolov3-v4 with own dataset for real-time object detection

I have a real-time problem which is aimed to detect 9 objects. As far as I understand, yolo has promising results on real-time object detection problems so I am searching good instructions to train a pre-trained yolo model with my custom "own" dataset.
I have my dataset and they are already labeled, also they have bounding box coordinates in .txt files in yolo format. However, it is a bit confusing to find a good instruction on the web about yolo custom dataset training for own object detection problem, since instructions are mostly using generic dataset such as COCO, PASCAL etc. or their instructions are not well enough to implement the object detection model on own dataset.
TL;DR
My question is, are there some handy instructions about implementing yolo object detection for own dataset? I am more looking for frameworks to implement yolo model rather than darknet C implementation since I am more familiar with python so it would be perfect if you could provide Pytorch or Tensorflow implementation.
It is more appraciated if you already implemented yolov3-v4 with your own dataset with the help of instructions you found on the web and you are willing to share those instructions.
Thanks in advance.
For training purpose I would highly recommend AlexeyAB's repository as it's highly optimised for accuracy and speed, although it is also written in C. As far as testing and deployment is considered you have a lot of options:
OpenCV's DNN Module: refer this article.
Tensorflow Model
Pytorch Model
Out of these OpenCV's DNN implementation is the fastest for testing/inference.

Problem in finding code for Simple image classification between two classes in android studio

i trained keras model on 2 classes and converted it into the .tflite model. now i want to use this model in android studio for simple classification between two classes when i put an image from the gallery. i can't find any help on internet regarding this simple way. On internet there is ways for camera but i don't need that in my simple project.
You will need to use TensorFlow Lite's Java API to run inference on-device. Start with the Android quickstart, if you haven't installed the dependencies etc.
If your model is similar to how standard image classification models (for eg MobileNet) work, you can start with the TFLite Image Classification app source for inspiration. Specifically, you might be interested in the Classifier base-class (and its floating point child class). Classifier demonstrates how you can use TFLite's Java API to instantiate a new Interpreter & run inference for image inputs.

How to recognize real scenes image using scikit-learn?

I am new in scikit-learn, I have a lot of images and images size not all same, A kind of are real scenes image like
cdn.mayike.com/emotion/img/attached/1/image/dt/20170920/12/20170920121356_795.png
cdn.mayike.com/emotion/img/attached/1/image/mainImg/20170916/15/20170916153205_512.png
, another are not real scenes image like
cdn.mayike.com/emotion/img/attached/1/image/dt/20170917/01/20170917011403_856.jpeg
cdn.mayike.com/emotion/img/attached/1/image/dt/20170917/14/20170917145613_197.png
.
I want to use scikit-learn recognizing which not real scenes image, I think it simlar to http://scikit-learn.org/stable/auto_examples/applications/plot_face_recognition.html#sphx-glr-auto-examples-applications-plot-face-recognition-py. I am totally no idea how to begin.How to creating dateset and extracting features from images? Can someone tell me what should I do?
This seems to not directly be a programming problem here and your questions are related to non-basic 'current' research.
It seems that you should read about Natural Scene (Statistics) and get yourself familiar with one of the current machine learning frameworks like TensorFlow, Caffe.
There are many tutorials out there to get started, for example you could begin with a binary classifier which outputs if the given image shows a natural scene or not.
Your database setup could have a structure like so:
-> Dataset
-> natural_scenes
-> artificial_images
Digits for example can use such a structure to create a dataset and is able to use models designed for Caffe and TensorFlow.
I would also recommend that you read about finetuning nerual networks, as you would need a lot of images in your database if you start training from scratch.
In Caffe you can finetune pretrained models like CaffeNet or GoogeNet.
I think those are some basic information which should get you started.
As of scikit-learn and face-detection: Face-Detection is more looking for local candidates or image patches which could possibly contain a face. Your problem on the other hand is more of a global problem as the whole image is concerned. That said I would start off with a neural network here which is able to extract local and global features for you.

OpenCV 3.0.0 SVM Trained Model Save / Load

I'm using OpenCV 3.0.0 and Python 2.7.9 to pull images of detected objects out of a live video stream and to categorize them as either being in a class of specific objects or not using the OpenCV Machine Learning (cv2.ml) Support Vector Machine (SVM).
The code that I use to train the SVM generates SIFT keypoints in the images, uses KMEANS clustering, and then feeds into the SVM training algorithm. All of that works fine, but because it isn't necessarily a part of the required operational code, I did it separately and save the SVM model to a .dat file using:
svm was created with cv2.ml.SVM_create()
svm.save('datafile.dat')
The problem is that the svm.load() function is not implemented at all in OpenCV 3.0.0.
I've tried to use the StatModel(model) to load as well and that didn't work either.
I'm pretty invested in the python portion of this project so far and would rather not re-program it as C++ and now that I have the SVM working on the training side, would prefer not to use something in SciPy.
I'm hoping that the load feature is somehow renamed and just not well documented. Any ideas?
Unfortunately it is a bug. See also this question.
If you check the help for SVM_create() you will see that there is no function like read() or load() but save() (inherited from Algorithm class):
>>> import cv2
>>> help(cv2.ml.SVM_create())

Which training method is used in cv2.createLBPHFaceRecognizer.train?

I am doing a project for recognizing expressions.my plan is to use LBP and SVM.For Implementing I choose Opencv and Python.I know that there is a inbuilt function createLBPHFaceRecognizer in opencv for LBP calculations.Which training method is used in createLBPHFaceRecognizer.train, is it SVM or K nearest or anything else?
I worked on a similar problem and if I was you, I would first detect face landmarks (best is DLib: http://dlib.net/webcam_face_pose_ex.cpp.html but in C++) then classify face points to get expression. They made something great in JavaScript (face landmarks, expressions classification - https://github.com/auduno/clmtrackr) but it is not pretty robust in detecting face landmarks.

Categories

Resources