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 https://funvision.blogspot.com


    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, RectangleToDraw.tl(), RectangleToDraw.br(), 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, RectangleToDraw2.tl(), RectangleToDraw2.br(), 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 https://funvision.blogspot.com

    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

    Video capture IP camera stream in opencv and people detection 

    Opencv video stream rtsp mjpeg

    In that tutorial, I just want to introduce how to read the more video streams in threads. In some cases you need to have FFMPEG installed. Hopefully, Windows nuger default instalation in Visual Studio should be enaught.. Let me know if there is some problem. 

    Opencv environmen for tutorial

    Just use the instalation of Opencv in Visual Studio 2015 by Nuget packages. In package console just type and wait for message that your opencv is succesfully instaled in your project. More info in tutorial Here
    Type to package console
    PM>  Install-Package opencvdefault

    On the Linux distribution i can recommend my tutorial Here. In case of Debian like packages.

    Opencv video stream verification

    rtsp://IP:PORT/various url

    Find your IP camera model on http://www.ispyconnect.com
    Select for example for Axis and the model..
    There is various stream url for each of this. There is no standard way of URL format.
    Find your for the camera and model.

    And milion of others different kind of URL formats.

    Opencv tutorial code IP camera pseudo code

    There is 3 function.. 
    First of all, the main function at the end, where are established 2 threads to read the camera stream..

    In Main
    • Thread call the stream function for both camera with different IP camera URL                       thread cam1(stream, "http://xxxxxxxR");
    • To run the function stream inside the thread with url as parametr use.                       cam1.join();
    void stream

    • Capture video from url strCamera VideoCapture cap(strCamera) 
    • Fill the frame from cap  cap >> frame;
    • Detect people in camera detect(frame, strCamera);
    void detect

    Opencv C++ IP camera code

    #include <iostream>
    #include <thread>
    #include "opencv2/opencv.hpp"
    #include <vector>
    using namespace std;
    using namespace cv;
    void detect(Mat img, String strCamera) {
      string cascadeName1 = "haar_cascade_for_people_detection.xml";
      CascadeClassifier detectorBody;
      bool loaded1 = detectorBody.load(cascadeName1);
      Mat original;
      vector human;
      cvtColor(img, img, CV_BGR2GRAY);
      equalizeHist(img, img);
      detectorBody.detectMultiScale(img, human, 1.1, 2, 0 | 1, Size(40, 80), Size(400,480 ));
      if (human.size() > 0) 
          for (int gg = 0; gg < human.size(); gg++) 
          rectangle(original, human[gg].tl(), human[gg].br(), Scalar(0, 0, 255), 2, 8, 0);
      imshow("Detect " + strCamera, original);
      int key6 = waitKey(40);
    //End of the detect
    void stream(String strCamera) {
    VideoCapture cap(strCamera);
     if (cap.isOpened()) { 
          while (true) {
            Mat frame;
            cap >> frame; 
            resize(frame, frame, Size(640, 480));  
            detect(frame, strCamera);
    int main() {
        thread cam1(stream, "http://xxxxxxxR");
        thread cam2(stream, "http://xxxxxxxR");
        return 0;

    Video stabilization by optical flow and median.. 

    opencv image stabilization optical flow median

    I have to say. This is only alpha version. First of all, I want to release video stabilization together with noise compensation, where i still have some mainly performance issue.. Secondary in some cases the result is not that good. Lets say, I need to fix better choice of the tracked features to stabiliza image.. 
    Secondary, I case that the scene is changing the video is little bit shaky.. Some second order filter or Kalman filter should resolve this easily.

    Enjoy the example

    Face features detection testing clandmark

    Face features detection opencv

    I like this project because some of the authors also teach me at CTU in Prague. This is just basic models free to use and test in Clandmark.
    I would like to pusblish tutorial how to use clandmark on my blog
    Need some time for basic research. I had not so well results under Visual Studio on windows. The optimization method is sensitive to precision of float type. I increase that precision by replacing one type inside the solver.. There is certainly smarter way how to achieve better results.

    You can download this product and test it as well from here. http://cmp.felk.cvut.cz/~uricamic/clandmark/

    Car detection video samples

    This is one of the results achieved by the free dataset for car detection on my blog here.  I have a plan to provide some basic scripts and code samples how to learn the basic detector for opencv. This usually take some time to go through and describe all the parts. However the plan is to provide whole video for testing on google drive after some anonymization improvements in original video. Testing rof car counting, classification and trafic measurement.. This Video is not good for basic background substraction. I record this video by hand and is still little bit shaky.

    car detection

    3 more opencv tutorials plan

    • working with dataset positive and negative samples 
    Prepare data is half of the hard work if you want to build the good detector.. 
    • some basic learning algorithm from scratch. (should take a little bit more time)
    I already have some neural network. I would like to show you how easy is for implement using the opencv mat and basic and opencv math.. 
    • working with createsamples traincascade
    This is great tool, but took some time, effort and skills to achieve some good results.. I would like to show some of them.. 

    Computer vision opencv car dataset 

    Opencv free car detection dataset for HAAR and LBP  classifier learning. Collect the positive samples should be boring and long term issue. For example negative samples is possible cut from random position and also random images. 

    car dataset detectioncar dataset machine learning opencv

    Licence for car dataset

    Use this version on your own risk. If you failed with learning the detector. I am not responsible for that. I am also not responsible if the dataset is not the perfect one for you. Please mention this blog as a source of the dataset and provide link here. It will be updated. 
    For research, personal use is available only with previously mentioned conditions. 
    For commercial use send me a gift card, sample of your product or what ever and respect the conditions above. THANKS

    What is in version 1 car dataset

    I just record the highway and extract cars from this sample by background substraction and save the detected rectangles. I do some raw cleaning by hand. Here is a download. Only the positive samples.. If you want also the negatives one. You can collect yourself of wait for the update..

    What will be next steps.
    • I will update the dataset. 
    • Prepare some utility 
    • Evaluation of the dataset
    • Learning example


    To the coments write me info about results achieved by the datasets. I still have no time to use this my new one.

    Denoising easy opencv tutorial C++

    The Opencv library has build in powerful denoising algorithm based on the non-local means. The metdod is based on the theory published in article by Antoni Buades, Bartomu Coll, Jean-Michel Morel  here. The algorithm is relatively simple, but not so easy to implement. Basically, one single pixel is replace by the average of the colors of area around the most simular pixel. Let say we want to replace pixel and algorithm finding the replacement in some window. It find the most simular replacement and additionally take a smaller window over that most silular replacement and calculate mean value over that. 
    If we have first window of some size and second the smaller just one pixel. We probably replace the original one with the most simular. If the most simular one is the noise. It will be noise. This is great metod for calculating the output image from the sequence of imputs image to achieve better result. Video result is also impresive.. Check the results and enjoy the simple code. 

    fastNlMeansDenoisingColoredMulti opencv denoising method results

    This results are from my video. Upper part of the image is the denoised frame of the video calculated from the 4 surrounded frames. Original imputs is the lower part of the image. If you check the cropped part below the results are clearly visible. No to much blured image, sharp edges and much less noisy. This is exactly what we want to achieve. 

    Denoising opencv noise reduction
    Denoising video sample in opencv 3,1 noise reduction
    Denoising opencv noise reduction

    Iphone sequence of images noise reduction

    I just take the imput 5 image by iphone SE holded in hands. Result will be much better with 5 images using tripod. 

    Denoising opencv noise reductionDenoising opencv noise reduction
    Denoising opencv noise reduction

    Denoising opencv noise reductionDenoising opencv noise reduction
    ZOOM of one of the imput image

    Denoising opencv noise reduction

    Results of  fastNl Means Denoising Colored Multi method

    Denoising opencv noise reduction

    Noise reduction Zoom ot the result

    Denoising opencv noise reduction

    What do you think ? Let me know.. 

    Opencv denoising (noise reduction) c++ code

    There is nothing special. Fill the vector<Mat> buffer(5); buffer with input images calculate from buffer the method based on the templateWindowSize = 12 and searchWindowSize = 48. This is it.

    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/photo.hpp>
    #include <opencv2\videostab.hpp>
    #include "opencv2/imgcodecs.hpp"
    #include "opencv2\highgui.hpp"
    #include "opencv2\imgproc.hpp"
    #include <iostream>
    using namespace cv; using namespace std; int main(int argc, char** argv) { vector buffer(5); Mat image; image = imread("i1.JPG", CV_LOAD_IMAGE_COLOR); buffer[0] = image; imshow("Display window", image); waitKey(2000); image = imread("i2.JPG", CV_LOAD_IMAGE_COLOR); buffer[1] = image; waitKey(2000); imshow("Display window", image); image = imread("i3.JPG", CV_LOAD_IMAGE_COLOR); buffer[2] = image; imshow("Display window", image); waitKey(2000); image = imread("i4.JPG", CV_LOAD_IMAGE_COLOR); buffer[3] = image; imshow("Display window", image); waitKey(2000); image = imread("i5.JPG", CV_LOAD_IMAGE_COLOR); buffer[4] = image; imshow("Display window", image); waitKey(2000); Mat img; int imgs_count = 5; fastNlMeansDenoisingColoredMulti(buffer, img, imgs_count / 2, imgs_count, 12, 48); namedWindow("Display window", WINDOW_AUTOSIZE); imshow("Display window", img); imwrite("result.jpg", img); waitKey(20000); return 0; }

    Denoising Colored Video example

    FastMeansDenoisingColoredMulti VS just DenoisingColored in Opencv with image stabilization video example

    opencv DenoisingColored

    C++ tutorial and code is here

    Smart noise reduction (denoise) Iphone SE video 

    I expect that i finish this tutorial until the end of this weak. This is what you can expect. Check my youtube video down on page. Opencv has awesome posibilities to remove noise in smart way. Much better results than dummy filters and blur methods.. 

    opencv noise remove compensation

    noise compensation opencv


    Multiple people tracking 

    Opencv tracking of multiple people example video and some ideas about the business behind.. 
    I would like to mention that this video is not related on my any curent business. This is just love to computer vision. 

    This short blog post should be about something else. 

    Multi target tracking

    Problem of computer vision business potencial

    • People point to any mistake of algorithm. Mistakes are visible. People dont care if the big data gives you huge statistics error. They are not able to count the milions line of something. 
    • They are able to count what they are really see on video. 
    Where is the point. Even the error is visible and sometines huge. This gives you better result than one man counting the people from the window all day long. 
    Are you able to track and monitor what every on screen doing and count targets and write the results somewhere. 


    Do not sell video. Sell the data

    This is important. Maybe the most important think. You are provide data about the day activity about the year activity what ever.  
    Not the person for one day counting of the trafic on the Prague town center crossing. 

    Video delivery or internet of things

    You have to solve the problem with stream video delivery to cloud as cheap as it posible. 

    There is one think. Internet of thinks. Maybe is better old aproach just manage the computer vision where the camera is located.. Computers are smaller and faster. The video delivery is problem.. You have to deal with so many problems. Insted of transfering just the data. 

    Benefits are that the people infront of the monitor just see your mistakes.

    Cost effective computer vision 

    There is maybe question what is effective. Process the video in cloud has also many advantages. Scales. Updates. Your algorithm is under control. You can handle what ever resolution. This is only issue of the cost of your solution. It is not necesary with some cameras to manage your own HW in that solution. 

    I have a lots of idea like that. I spent lots of time not only on algorithm itself. For example another huge topic is 

    Self configuration of computer vision algorithm

    Yes this one. Not a spend 3 hours or months to make perfect youtube video. There is no reason. 
    Algorithm should be somehow self configurating.  And it may not be perfect. Let the rest of the world accept error also in computer vision. 

    Have a nice evening and let me know. What do you think. 

    Tutorial comming soon. Hopefully 

    Opencv Tutorial colors channels

    Opencv C++ simple tutorial about the colors and color channels. There is couple of tricks you can play with in Opencv. It is fun and easy to use to achieve color mixing and gain the channel by for example slide bar.. Enjoy the coding.. 

    Opencv installation in Visual Studio 2015

    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 

    opencv colors channels

    Opencv colors introduction

    I always forget what is the right order of colors in the opencv. The purpose of this short tutorial is different. It is not necessary to know if the blue rectangle in RGB should be defined like [255 , 0 , 0] or [0, 0 , 255] . Hopefully it is still BGR that mean blue, green and red channel. Just to be clear and sure that anyone understand. You can change that order but for no reason the default order is BGR.

    There is more color space available in opencv and in practice there is a reason for that. There is also different scales for each colors.

    Example is simple. BLUE should be 0 to 255 for min and max value of the channel (CV_8U). Same blue color can have a same min and max visual levels but color is divided into more steps 0 to 65535(CV_16U).

    Opencv color space transformation basics

    There is also pure gray scale. GRAY is equal of small piece of blue plus small piece of green and small piece of the last one. Something like Gray = 0.3 x R + 0.3 x G + 0.3 x B. Ok constants are different but who cares if there is 0.299 in R channel and lots of green color. This is it in principle.

    Also there is much more color spaces. Some of than are better because of let say endurance against the intensity of light conditions.

    But all you need to know for beginning is just cvtColor command.

    Comand has 3 parameters. Input_Image and output_Image and from_to_color_space.

    cvtColor( YourMat, YourOutputMat, CV_BGR2GRAY); sometimes in opencv 3.1 is only BGR2GRAY.

    You can use transformation to CV_BGR2HSV and back should be CV_HSV2BGR. ALL make sense but no BGR in world, where everyone using RGB.

    Opencv tutorial Video color mixing

    In this tutorial there is only one milestone. Learn this 
    IMage.at<Vec3b>(y, x)[0]    to Access the pixel at Y and X position. !For 0 color channel. 
    and this 
    IMage.at<Vec3b>(y, x)[1]    Same but different color. 
    and also 
    IMage.at<Vec3b>(y, x)[2]    This should be Blue or Red thats depends on Opencv mood. Probably red.

    In tutorial we make a copy of the image by

    Into that copy just insert the image retrieve by video capture and each pixel of each color channel just multiply by value of slider. 

    Opencv dependencies 

    The code is well described and in right setting of Opencv 3.1 instalation works. For example the easies instalation in Visual studio is by NUGET packages described here 

    Proper setting of the video writer it should be found Here. The only magic is right instalation and proper size of output image. Ok codec also. 

    Opencv Video color channels example

    Opencv tutorial code

    #include "opencv2\highgui.hpp"
    #include "opencv2\imgproc.hpp"
    #include <vector>
    #include <stdio.h>
    #include <Windows.h>
    #include <iostream>

     using namespace cv;
    using namespace std;

    // slider globa value
    int iSliderValue1 = 0;
    int iSliderValue2 = 0;
    int iSliderValue3 = 0;

    int main(int argc, const char** argv)
     // read video or cap(0) the web cam
    VideoCapture cap("mov.MOV");

    //prepare the writer for output
    VideoWriter outputVideo;

    outputVideo.open("video4.wmv", CV_FOURCC('W', 'M', 'V', '2'), 30, Size(1280, 960), true);

    for (;;)

    bool Is = cap.grab();
    if (Is == false) {
            cout << "Video Capture Fail" << endl;
    else {

    Mat img;
    Mat Original;
    cap.retrieve(img, CV_CAP_OPENNI_BGR_IMAGE);
    resize(img, img, Size(1280, 960));
    // we got a video in img and its copy in Original
    // Lets access all pixels in X and Y (Y,X) and also visit all colors [0-2]

    for (int x = 0; x < img.cols -1 ; x++)
    for (int y = 0; y < img.rows -1 ; y++)

    //Rewrite Original copy by IMG multipy by some value based on SLIDER value
    Original.at<Vec3b>(y, x)[0] = img.at<Vec3b>(y, x)[0]* (iSliderValue1 )/200  ;
        // Do it for another color
    Original.at<Vec3b>(y, x)[1] = img.at<Vec3b>(y, x)[1]* (iSliderValue2 )/200 ;
        // If you wat also for the last one
    Original.at<Vec3b>(y, x)[2] = img.at<Vec3b>(y, x)[2]* (iSliderValue3 )/200 ;


    // Simple slider , parameters are some description R, G and B
    // also some window prew, and update some value
    // the last parameter 215 is maximum value.....
    createTrackbar("R", "prew", &iSliderValue1, 215);
    createTrackbar("G", "prew", &iSliderValue2, 215);
    createTrackbar("B", "prew", &iSliderValue3, 215);

    // show the result
    namedWindow("prew", WINDOW_AUTOSIZE);
    imshow("prew", Original);
    // write the output
    outputVideo << Original;

    int key1 = waitKey(20);


    Share if you like it... Thanks :) 

    Opencv people tracking by head detection

    Opencv head detection is much more complicated than the whole body detection.. Learning is the same. All the steps are the same. There is some aspects which just complicate the situation with head detection. First one is that the result detecting the head has more false detection than in case of whole body. There is also important the performace issue. You need to detect in detect multiscale approach just smaller sliding window than in case of whole people detection. That dramatically decrease the performance. The result of the detection should be very slow also on small resolution. 

    There is also some positive aspects of head detection. You can simly in multi target tracking example just connect the detection with the tracking history.. That is the main advantage.. 

    opencv tracking

    opencv tutorial

    Opencv Simple instalation.

    Easy Opencv instalation  for Visual Studio 2015 C++ project by NUGET packages. Your opencv is ready to use under 2 minutes after you find the package console.  

    From Opencv 3.0 Cmake to Opencv 3.1 prebuild Libs

    I wrote about opencv instalation since the release of version 3 and Visual Studio 2015.. In early build of opencv 3.0 there is no precompiled library for VS2015 and I wrote about instalation using CMAKE here . This is still usefull when you need non standard capabilities. You can manage build process and target specific functions and properties. Opencv version 3.1 was shipped with prebuild libs for Visual studio 2015 and everithing is much more simple.. Instation and basic setup is discussed in tutorial here .

    Install Opencv, Visual studio 2015 with NUGET

    The most simple way without setting the global enviromental variables and staff like location of headers and libs is use the NUGET packages.. 

    You can install in nuget package console.. DONT be afraid of CONSOLE. PLEASE. 

    1.Open Nuget console 

    2. Create empty Visual C++ project

    3. Add a source File and write some code.. 

    4. Add NUGET package

    5. Compile and have a fun.. RLY simple in less than 4 minutes.. 

    Again please dont be afraid of console again.. This is much more simple than anaything.. 

    Opencv Nuget Console options 

    After the PM> you can write commands for Nuger console.. And install Opencv is rly simple. For default configuration like in prebuild libs just use.. 

    Opencv Default Build 3.1.0

    PM>  Install-Package opencvdefault

    Enabled advanced CPU instructions. With OpenMP. No TBB/IPP. vc12/vc14, x64/x86 available.

    PM>  Install-Package opencv3.1

    AND DONE !!


    Opencv NUGET console

    Opencv install

    Opencv 3.1

    Opencv Installation NUGET

    Opencv Install

    opencv 3,1 nuget

    opencv 3.1 nuget instal visual studio

    My iceland video tracking example

    Video tracking stabilization opencv

    i know that, I did not write anything interesting for a long time.. I am working on it..

    Transparent mask tutorial is Here

    Feel free to share this article.. Thanks a lot

    Microsoft cognitive-services VS Google Vision API

    Simple comparison of result of Microsoft cognitive-services VS Google Vision API. Check the results achieved by 2 somehow simular example.. 

    Which image api recognition engine is bigger gentleman ?

    Check the result.. This is just a funny comparison.. I did not mean this rude. You get it, when you check the result of this outstanding api..  Microsoft has realy truly stunning results. 

    Microsoft cognitive-services VS Google Vision API

    Microsoft cognitive-services image clasification result

    { "text": "a beautiful woman standing on a beach", "confidence": 0.6798031586203954 }

    There is much more information about the image and they are impresive.. A beautiful woman.. Ok lets check google result,, 

    Google vision api More neutral 

    and let say, More or less ok.. 

    "description": "clothing",  "description": "vacation", ¨description": "beauty", 
      "description": "photo shoot",  "description": "sun tanning",  "description": "sports",
     "description": "volleyball",

    Microsoft cognitive-services VS Google Vision API

    Microsoft cognitive-services image clasification result

    { "text": "a woman walking down a beach next to the ocean", "confidence": 0.5507436156974482 } ] }

    Google vision api More neutral 

    "description": "clothing", "description": "vacation", "description": "black hair", "description": "beauty", "description": "sea", "description": "model", "description": "swimwear",  "description": "supermodel",  "description": "photo shoot",

    I will be back soon. Tutorials and more about Computer vision, technology and more

    Blog techblog computer vision

    Fotka zveřejněná uživatelem @vladakuc,
    Fotka zveřejněná uživatelem @vladakuc,

    Fotka zveřejněná uživatelem @vladakuc,


    Follow by Email

    Powered by Blogger.