hadign20 / Unsupervised-Video-Object-Detection

Foreground detection in videos captured by moving cameras, Source code of paper: "Real-Time Hysteresis Foreground Detection in Video Captured by Moving Cameras"
14 stars 2 forks source link

input frame #1

Open SabraHashemi opened 12 months ago

SabraHashemi commented 12 months ago

your code can not work with a 1920x1080 frame (it will crashed) how can i improve the code to run on any videos?

hadign20 commented 12 months ago

Hi I tried with a larger video (3840x2160). It is slow but didn't crash. You can set the DEBUG values to 0. Also, try increasing the block size and window size to see if it speeds up. In general, it's better to scale down the input videos to avoid slow processing. You can set the scale variable to true for this.

SabraHashemi commented 11 months ago

but i have got below error when i want to run on Size : 1920X1080 but if ran it on woman.mp4 video it works error text : OpenCV(3.4.1) Error: Assertion failed (cn <= 4) in scalarToRawData, file /home/sabra-pc/Projects/Moving-Objects/DCFG/opencv_install/opencv-3.4.1/modules/core/src/array.cpp, line 3232 Aborted (core dumped)

this error happened in KLT function:

void DCFG::KLT(cv::Mat& imgGray) {
#if DFCG_DEBUG
    cv::RNG rng(12345);
    colorFrame.copyTo(testImg);
#endif

    if (!points[0].empty())
    {
        calcOpticalFlowPyrLK(prevGray, imgGray, points[0], points[1], status, err, winSize, 3, termcrit, 0, 0.001);
        size_t i;
        for (i = count = 0; i < points[1].size(); i++)
        {
            if (!status[i])
                continue;
            nMatch[count++] = i;
#if DFCG_DEBUG
            cv::Scalar color = cv::Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
            circle(testImg, points[0][i], 3, color, -1, 8);
            circle(testImg, points[1][i], 3, color, -1, 8);
            cv::arrowedLine(testImg, points[0][i], points[1][i], color, 1);
#endif
        }
    }

#if DFCG_DEBUG
    imshow("LK Demo", testImg);
#endif
SabraHashemi commented 11 months ago

also I have set the Debug Flag to 0 but still I have got this error : ./DCFG ~/Datasets/f.mp4 Processing f ...0 Segmentation fault (core dumped)