November 2016

Follow

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
  • 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

    http://IP:PORT/mjpeg/video.mjpg?counter
    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.
    rtsp://IP:PORT/axis-cgi/mjpg/video.cgi
    http://IP:PORT/mjpg/video.mjpg

    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;
      img.copyTo(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");
        cam1.join();
        cam2.join();
        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
    http://funvision.blogspot.com
    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

    DOWNLOAD   HERE


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








    ad