December 2016


My favourite

  • Opencv tutorial people detection
  • Head people cascade download
  • Opencv tutorial optical flow
  • Opencv Video stabilization
  • Opencv car dataset download
  • Opencv tutorial Transparent mask
  • Opencv videowriter
  • Opencv FFMPEG
  • Opencv Canny edge and hough lines
  •  head and people detection Opencv LBP CascadeClassifier 

    This LBP cascade for opencv will be available soon. People is just new version of the old one published here. Head detection is new one. Just trained.

    LBP cascade description

    I trained cascade just on hopefully well selected 2000 positive images and 2400 negative. Great effect has also selection of the negative samples. I need to find more about this. Same positive samples and different negative set of samples should lead to big different kind cascade property. Yes positive samples is good to have somehow unique (situation, positive, background, rotation etc). The negative samples are simple to capture. Random crop from the several pictures from vacation. Nothing special. But there is also the magic behind. Instead of try different kind of positive samples. Try the negative. Easy to collect and performance of the cascade should be rapidly different. Also, It is not necessary to have 100 percent clear negative sample. If there is 1 positive inside the negative set. Maybe more. It is not necessary something wrong. More details after release.... Soon hopefully


    LBP cascade for Car detection in Opencv

    LBP ( included to download) and Haar features in opencv detectMultiscale are one of the most simple and also powerfull (Old sure) to detect something. In this article is pre trained LBP cascade for car detection. Code and basic info. Results are not that bad. Check the video and enjoy pretrained cascade.

    Car LBP cascade detection opencv

    Opencv cascade for car detection conditions of use

    Also, Do not worry about the condition of use. Use only on your own risk. That's it. The dataset to train this cascade is only mine. I also colect positive and negative data. I just want to say, that there is also no conditions based on the datasets. There is no others conditions of use. Maybe check the Opencv traincascade utility. Thanks. Yes share and cite. Just small minimal condition.

    Download HERE

    LBP cascade properties

    This is just basic 5 stage haar cascade car detector develop by 
    V.K. from


    Opencv video results

    Set Opencv Project in VS2015

    You can simple prepare the project inside the Visual Studio 2015 by Nuget Packages. This approach is easy for beginers and better than standard installation with all the environmental variables problems. Just follow the installation steps inside here

    How to use LBP cascade in OPENCV

    Just Copy downloaded cascade inside the VS 2015 project dir. 
    Visual Studio 2015\Projects\CarProject\CarProject

    Facebook page is out. Stay tuned to more tutorials, news and updates.

    Opencv rectangle drawing tutorial C++

    Opencv rectangle drawing tutorial by example in C++. Simple steps let you draw the rectangle inside the pictures and video sample. Several rectangle definition and redtagle drawing function just show you various way to draw the rectangles inside the picture and video.. It is simple and easy. 

    Steps in descriptions rectangle drawing 

    All the steps below the picture (A B ... F) are also marked inside the code. The commends inside c++ code // just describe the Rect definition to define rectangle to draw inside the function rectangle. This function just draw the defined rectangle inside  Picture.  Rectangle(Picture is the first parameter. This is just Mat where to put the second parameter. Defined Rect (rectangle). You can choose to put the rectangle to that function in several way. This is not 2 much important. They just do the same job for you.. I am using just one of them. 

    Try to figure out the steps and compare the code with images.. 
    Third parameter is most likely the color of the Rectangle. Color is described by 3 numbers Scalar(B,G,R). B for Blue, G for green and R for the last one. You now the color very well 

    There is 3 more parameters. After the color there is the thickness of the line. Use whatever you want. Another one is type of the line. For me is this parameter always 8. I dont care about the dashed and solid line type.. The last is shift. What the hell is that. I know but do not care. 

    Try the code and compare the steps and code.. Enjoy 

    Opencv draw rectangle
    Opencv rect Step A in code

    Opencv draw rectangle
    Opencv rect Step B in code

    Opencv draw rectangle
    Opencv rect Step C in code

    Opencv draw rectangle
    Opencv rect Step D in code

    Opencv draw rectangle
    Opencv rect Step E in code

    Opencv draw rectangle
    Opencv rect Step F in code

    Opencv c++ tutorial draw Rectangle code

    #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <opencv2/videoio.hpp> #include <opencv2/objdetect.hpp> #include <opencv2/imgproc.hpp> #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { Mat Picture; Picture = imread("22.JPG"); resize(Picture, Picture, Size(800, 600)); //A Parameters x (start in x axes horizontal) y (start in vertical) // w (vertical lenght) h (Horizontal lenght) Rect RectangleToDraw(10, 10, 100, 100); rectangle(Picture,,, Scalar(0, 0, 255), 2, 8, 0); imshow("DrawRectangle", Picture); int key4 = waitKey(2000); // save imwrite("1.jpg", Picture); //B Rectangle defined by 2 points Point A(10, 10); Point B(100, 100); Rect RectangleToDraw2(A, B); rectangle(Picture,,, Scalar(0, 255, 255), 1, 8, 0); imwrite("2.jpg", Picture); //C x=100, y=100, w=300, h=300 Rect RectangleToDraw3(100,100,200,200); rectangle(Picture, RectangleToDraw3, Scalar(0, 250, 0), 2, 8, 0); imwrite("3.jpg", Picture); //D Scalar(255, 0, 0) Color parameter // Blue 255, Green 0, Red 0 Rect RectangleToDraw4(300, 300, 100, 100); rectangle(Picture, RectangleToDraw4, Scalar(255, 0, 0), 2, 8, 0); imwrite("4.jpg", Picture); //E 10 value, int is thickness of the line Rect RectangleToDraw5(300, 300, 100, 100); rectangle(Picture, RectangleToDraw5, Scalar(255, 0, 255), 10, 8, 0); imwrite("5.jpg", Picture); //F Rect defined inside drawinf function // 4 value is line type rectangle(Picture, Rect(400,400,50,50), Scalar(255, 255, 255), 2, 4, 0); imwrite("6.jpg", Picture); imshow("DrawRectangle",Picture); int key7 = waitKey(20); return 0; }

    Opencv traincascade haar and lbp training 

    Opencv traincascade script parameter examples for windows. Traincascade utility is easy to use for training HAAR like and LBP like cascade for opencv detect multiscale by CascadeClassifier. On this blog you can find several example how to detect something by the HAAR a nd LBP cascade..

    Opencv LBP detection

    Opencv traincascade examples

    I am using this parameters. You can start where you just ended before. This make sense. Train for 5 stages and test. If the results with higher treshold make sense. Train again with same script and increase numStages. After some time training is much and much slower and test before you run the training for the long time. 

    This is my scripts.. If you have any

    opencv_traincascade.exe -data v -vec vec.vec -bg bg.dat -numPos 300 -numNeg 300 -numStages 10  -numThreads 2 -stageType BOOST -featureType LBP -w 32 -h 64 -minHitRate 0.995 -maxFalseAlarmRate 0.42 -maxDepth 1 -maxWeakCount 100

    opencv_traincascade.exe -data vv -vec vec.vec -bg bg.dat -numPos 540 -numNeg 800 -numStages 8  -numThreads 4 -stageType BOOST -featureType LBP -w 32 -h 64 -minHitRate 0.9995 -maxFalseAlarmRate 0.32 -maxDepth 5 -maxWeakCount 120

    opencv_traincascade.exe -data cascade -vec vec.vec -bg bg.dat -numPos 680 -numNeg 800 -numStages 10 numThreads 4 -stageType BOOST -featureType LBP -w 32 -h 64 -minHitRate 0.999995 -maxFalseAlarmRate 0.42 -maxDepth 10 -maxWeakCount 120 -mode ALL

    opencv traincascade documentation description

    Later abou this.. Complex staff. Just try example if you have some datasets prepared or know the how to prepare vector_file and background file for training.

    Usage: opencv_traincascade.exe
      -data <cascade_dir_name>
      -vec <vec_file_name>
      -bg <background_file_name>
      [-numPos <number_of_positive_samples = 2000>]
      [-numNeg <number_of_negative_samples = 1000>]
      [-numStages <number_of_stages = 20>]
      [-precalcValBufSize <precalculated_vals_buffer_size_in_Mb = 1024>]
      [-precalcIdxBufSize <precalculated_idxs_buffer_size_in_Mb = 1024>]
      [-numThreads <max_number_of_threads = 9>]
      [-acceptanceRatioBreakValue <value> = -1>]
      [-stageType <BOOST(default)>]
      [-featureType <{HAAR(default), LBP, HOG}>]
      [-w <sampleWidth = 24>]
      [-h <sampleHeight = 24>]
      [-bt <{DAB, RAB, LB, GAB(default)}>]
      [-minHitRate <min_hit_rate> = 0.995>]
      [-maxFalseAlarmRate <max_false_alarm_rate = 0.5>]
      [-weightTrimRate <weight_trim_rate = 0.95>]
      [-maxDepth <max_depth_of_weak_tree = 1>]
      [-maxWeakCount <max_weak_tree_count = 100>]
      [-mode <BASIC(default) | CORE | ALL

    13 stage opencv LBP cascade for people detection

    My Opencv LBP 13 stage cascade for people detection. It is only 13 stages learned on 300 of positive people images. It is not trained enaught. Training time is only under 1 hour. I have also more trained version also on 300 people. They are just under testing. This is just what i want to release to public. Enjoy The cascade. It is not that bad. You need to only set the higher minNeighbors parameterAs I sayd it is not trained a lot.

    opencv haar LBP cascade

    Opencv cascade for people detection conditions of use

    Also, Do not worry about the condition of use. Use only on your own risk. That's it. The dataset to train this cascade is only mine. I also colect positive and negative data. I just want to say, that there is also no conditions based on the datasets. There is no others conditions of use.

    Cascade classifier LBP great but real value is in Datasets

    This cascade is just example achieved in 2 hours. One hour of training and the previous one for try to find right configuration and testing. There is much more time in prepairing the dataset for testing and also for learning. I like to train cascade on more training images and also for more situation. All is matter of time. Nothing else. Only time, Sure there is nothing valuable than time. 

    LBP cascade trainig ( traincascade ) parameters

    Utility is just traincascade.exe distributed with Opencv 3.1 version. Parameters are just like this.
    -data v -vec vec.vec -bg bg.dat -numPos 300 -numNeg 300 -numStages 13  -numThreads 4
    -stageType BOOST -featureType LBP -w 32 -h 64 -minHitRate 0.995 -maxFalseAlarmRate 0.42
    -maxDepth 1 -maxWeakCount 100
    There is one performace advice. If you have a cloud computer just focus on memory. To speed up
    the learning process just increase precalcValBufSize and precalcIdxBufSize. One year ago i have 
    set up Azure server for learning and  64 GB of ram is better than more cores. I would like to write something later about that. It was great to have this kind of computer and 30 000 well prepared 
    positive examples for learning. 

    How to use LBP cascade in OPENCV

    This code helps you to use the cascade. Complete code you can find in previous article for Car detection in opencv
     vector human;
     cvtColor(img, img, CV_BGR2GRAY);
     equalizeHist(img, img);
     detectorBody.detectMultiScale(img, human,1.1,50,0|1,Size(5, 10),Size(300,480 ));
     if (human.size() > 0) {
      for (int gg = 0; gg < human.size(); gg++) {
                     rectangle(img, human[gg].tl(), human[gg].br(), Scalar(0, 0, 255), 2, 8, 0);

    LBP cascade
     OPENCV LBP Cascade parameters 

    <?xml version="1.0"?>
    This is just basic 13# stage haar cascade pedestrian detector develop by 
    V.K. from

    OPENCV LBP Cascade download HERE

    If you want to train some cascade. Just download my dataset for cars. It is also for free
    See also my car dataset