Ask Your Question

Liphoto's profile - activity

2019-06-23 15:08:03 -0600 received badge  Notable Question (source)
2018-08-22 00:36:25 -0600 received badge  Popular Question (source)
2016-07-25 03:49:02 -0600 commented question assigning ID to individual blobs

That is the code I followed. I am unable to find out where the blobID is created if at all. I believe below is the code in which a new Blob is created

void addNewBlob(Blob &currentFrameBlob, std::vector<Blob> &existingBlobs) 
{

    currentFrameBlob.blnCurrentMatchFoundOrNewBlob = true;
    existingBlobs.push_back(currentFrameBlob);  
}

in the with the blow function he checks if the line has been crossed. I would like to have the ID of each car as it passes the line

bool checkIfBlobsCrossedTheLine(std::vector<Blob> &blobs, int &intHorizontalLinePosition, int &carCount, VideoCapture& cap)

I am intrested in determining the speed of only the vehicles that have crossed the line. for that i am using a separate piece of code and would like to match a blobID to a carID

2016-07-25 02:31:42 -0600 asked a question assigning ID to individual blobs

Please assist. Is there any way I can assign detected blobs ids such that I can then refer to each from any where else in my code. say I want the first blob detected to have an ID = 001, second =002, ..., nth = 00n.

2016-07-25 02:12:01 -0600 commented question getting frame number from Mat

Thank you very much

2016-07-22 08:07:44 -0600 asked a question getting frame number from Mat

Is it possible to get a frame number from a Mat object? From a VideoCapture object it would be

cap.get(CAP_PROP_POS_FRAMES)

is there a function for getting the current frame number from the Mat

2016-07-22 02:40:49 -0600 received badge  Enthusiast
2016-07-20 10:35:59 -0600 commented answer finding speed of vehicle in video

from a mathematical point of view I understand everything you are saying I should do. I just dnt know how to code it. I got this far by following tutorials and examples. the code I have draws boxes around each car after running background subtraction. as each box is drawn a counter counts the number of boxes drawn and returns the total number of boxes hence the number of cars. am very new to opencv and learning as I go. How would I find the time and the frame at which a car is observed and leaves the scene? I understand what I need to do but have struggling with the code.

2016-07-20 09:40:02 -0600 commented answer finding speed of vehicle in video

May you please assist me with a code snippet. I have been able to get the frame rate total number of frames with the blow code

   void video_details(VideoCapture& cap)
  {

cout << "The video has  " << cap.get(CAP_PROP_FRAME_COUNT) << "  frames" << endl;
cout << "The video is playing at  " << cap.get(CV_CAP_PROP_FPS) << "   frames per second." << endl;
 }

I do not know how to get the remaining variables in order to get the speed. Thank you for the response

2016-07-20 09:24:50 -0600 answered a question Detection and counting cars - OpenCV and C ++

I tried the above code but I always get my count as 0

2016-07-20 08:50:56 -0600 asked a question finding speed of vehicle in video

Can you please assist me with getting the speed of vehicles in a video. I have googled a lot on this but I could not find a solution. My task was to count cars and get the speed of every car and save to a stack/array. I have been able to count the cars but I an not sure how to calculate the speed. I had imagined I would do it in this manner.

  1. T= Total number of frames in the video
  2. t(enter) = the time at which one vehicle enters the scene
  3. t(leave) = the time at which the same vehicle leaves the scene
  4. T(frame) = the total time consumed by one frame
  5. T(total) = the total number of frames that were consumed by the vehicle to enter and leave the scene
  6. d = the total distance(in meters) of the road; the distance of the road that is on interest: the real distance.

I was then hoping that speed in KM/h may be calculated as follows speed = d/[t(left)-t(enter)]

I was then hoping to take each of the speeds and save then to a stack/array for further processing.

I am not sure if this is the correct way of processing speed from a video.

Thank you in advance.

2016-06-10 04:46:27 -0600 asked a question vehicle tracking on OpenCV2.4.11

I am very new to openCV and am using 2.4.11 on visual studio 2015 I have the below code that I got off a tutorial. The code is supposed to play a video and run back ground subtraction. The code runs at times but at other times I get an

debug assertion failed _block_type_is_valid(phead- nblockuse)

How may I solve this? In addition, I aslso get arn error at

imshow("MOG", fgMaskMOG);

Is there a tutorial I can read that can show me how to buils an application that can count the number of cars passing a a camera as well as get the avarage speed at which the cars are travelling. have trie to google to find tutorials but all I find are video on youtube.

#include<opencv2\opencv.hpp>
    #include<opencv2/core/core.hpp>
    #include<opencv2/highgui/highgui.hpp>
    #include<opencv2/imgproc/imgproc.hpp>
    #include<opencv2\video\background_segm.hpp>

    #include<stdio.h>
    #include<iostream>


    using namespace std;
    using namespace cv;

    ///////////////////////////////////////////////////////////////////////////////////////////////////
    int main() 
    {
        Mat frame;
        Mat resizeF;
        Mat fgMaskMOG;
        Mat fgMaskMOG2;
        Mat fgMaskGMG;

        Ptr<BackgroundSubtractor> pMOG;
        Ptr<BackgroundSubtractor> pMOG2;
        Ptr<BackgroundSubtractorGMG> pGMG;

        pMOG = new BackgroundSubtractor();
        pMOG2 = new BackgroundSubtractorMOG2();
        pGMG = new BackgroundSubtractorGMG();
        //char filename[100] = "C:\\Users\\User\\Documents\\Visual Studio 2015\\Projects\\My OpenCV\\Template\\/video.avi";
        VideoCapture stream1("video 2.mp4");

        Mat element = getStructuringElement(MORPH_RECT, Size(3, 3), Point(1, 1));
        while (true)
        {
            Mat cameraFrame;
            if (!(stream1.read(frame)))
                break;
            resize(frame, resizeF, Size(frame.size().width / 4, frame.size().height / 4));
            pMOG->operator()(resizeF, fgMaskMOG);
            pMOG2->operator()(resizeF, fgMaskMOG2);
            pGMG->operator()(resizeF, fgMaskGMG);
            //morphologyEx(fgMaskGMG, fgMaskGMG, CV_MOP_OPEN, element);

            imshow("Origin", resizeF);
            //imshow("MOG", fgMaskMOG);
            imshow("MOG2", fgMaskMOG2);
            imshow("GMG", fgMaskGMG);

            if (waitKey(30) >= 0)
                break;
        }


        //system("pause");
        return(0);
    }