Ask Your Question

teddybur13's profile - activity

2016-09-18 06:15:49 -0600 asked a question How to detect vehicle in opencv 3.1? Im using C++

I used this code but it detects many objects in the video:

using namespace cv; using namespace std;

int main() {

//global variables Mat frame; //current frame Mat back; Mat fore, fMOG2, fKNN; Mat resizeF; Mat fgMaskMOG; //fg mask generated by MOG method String stat= "Unoccupied";

Ptr<backgroundsubtractormog2> pMOG; //MOG Background subtractor pMOG = createBackgroundSubtractorMOG2(); pMOG->setNMixtures(3); pMOG->setDetectShadows(0);

Ptr<backgroundsubtractorknn> pKNN; pKNN = createBackgroundSubtractorKNN(); pKNN->setDetectShadows(0);

//rect //int largest_area=0; //int largest_contour_index =0; vector<vector<point> > contours; vector<vec4i> hierarchy;

VideoCapture stream1(0); //0 is the id of video device.0 if you have only one camera

while(1){ Mat cameraFrame, cont, thresholds; if(!(stream1.read(frame))) //get one frame form video break;

    pMOG->apply(frame, fore);
    pKNN->apply(frame, fKNN);

    pMOG->getBackgroundImage(back);
    erode(fore, fore, Mat());
    dilate(fore, fore, Mat());

    //working con
    //findContours(fore, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    //drawContours(frame, contours, -1, Scalar(0,0,255),2);

    //contour
    //vector<Vec4i> hierarchy;
    //findContours(frame, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0)); //detect contours

    findContours(fore, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); //working_on
    vector<vector<Point> > contours_poly(contours.size());
    vector<Rect> bounding_rect(contours.size());

    /*
    for(int i =0; i<contours.size(); i++){
        double a= contourArea(contours[i], false);
        if(a>100){
            approxPolyDP(Mat(contours[i]),contours_poly[i],3,true);
            bounding_rect[i] = boundingRect(Mat(contours_poly[i]));
        }
    } */

    for(int i=0; i < contours.size(); i++){
        double a= contourArea(contours[i], false);

        //set the area size for which the program detects the object as vehicle
        if(a>500){
            approxPolyDP(Mat(contours[i]),contours_poly[i],3,true);
            bounding_rect[i] = boundingRect(Mat(contours_poly[i]));
            //largest_area=a;
            //largest_contour_index=i;
            //bounding_rect=boundingRect(contours[i]);
            rectangle(frame, bounding_rect[i].tl(), bounding_rect[i].br(),Scalar(0,255,0),1,8,0);
            stat = "Occupied";
        }
        else{
            stat = "Unoccupied";
        }
    }

    Scalar color(255,255,255);
    //drawContours( frame, contours,largest_contour_index, color, CV_FILLED, 8, hierarchy );
    //drawContours(frame, contours, -1, Scalar(0,0,255),2); //working
    //rectangle(frame, bounding_rect, Scalar(0,255,0),1,8,0);
    putText(frame, "Lot Status: "+stat, Point(10,20), FONT_HERSHEY_SIMPLEX, 0.5,(0,0,255),2,8);

    imshow("Origin", frame);
    imshow("MOG2", fore);
    //imshow("KNN", fKNN);
    //imshow("contour", frame_dupe);


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

}

}

2016-09-17 21:35:17 -0600 asked a question How to build opencv 3.1 libraries in Windows 10 64bit? That I can use in Eclipse IDE

Im trying for days now on building opencv 3.1.0. I followed this method( http://cookyourpc.blogspot.com/2015/0...) Everything works fine until in buidling the opencv libraries (Cmake part) everytime i run "mingw32-make" i always encounter this error:

Used Versions: 1. OS:Windows 10 64 bit 2. OpenCV: OpenCV 3.1.0 3. MingW: mingw64 (used mingw32 6.2.0) 4. Cmake: cmake 3.6.2 -win32- x86

Linking CXX executable ....\bin\opencv_perf_core.exe ../../lib/libopencv_ts310.a(ts.cpp.obj):ts.cpp:(.text$_ZN6cvtest2TS4initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x119): undefined reference to `cv::redirectError(int ()(int, char const, char const, char const, int, void), void, void)' collect2.exe: error: ld returned 1 exit status modules\core\CMakeFiles\opencv_perf_core.dir\build.make:858: recipe for target 'bin/opencv_perf_core.exe' failed mingw32-make[2]: [bin/opencv_perf_core.exe] Error 1 CMakeFiles\Makefile2:1543: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/all' failed mingw32-make[1]: [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2 Makefile:159: recipe for target 'all' failed mingw32-make: * [all] Error 2

2016-09-17 21:16:21 -0600 commented question Is anyone know how to use opencv 3.1 in eclipse ide? (windows 64bit) ive searching for days now and still cant figure out how. Ive tried some methods but when I run the "mingw32-make" i always got errors.

Linking CXX executable ....\bin\opencv_perf_core.exe ../../lib/libopencv_ts310.a(ts.cpp.obj):ts.cpp:(.text$_ZN6cvtest2TS4initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x119): undefined reference to `cv::redirectError(int ()(int, char const, char const, char const, int, void), void, void)' collect2.exe: error: ld returned 1 exit status modules\core\CMakeFiles\opencv_perf_core.dir\build.make:858: recipe for target 'bin/opencv_perf_core.exe' failed mingw32-make[2]: [bin/opencv_perf_core.exe] Error 1 CMakeFiles\Makefile2:1543: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/all' failed mingw32-make[1]: [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2 Makefile:159: recipe for target 'all' failed mingw32-make: * [all] Error 2

2016-09-17 19:04:53 -0600 received badge  Editor (source)
2016-09-17 18:30:55 -0600 asked a question Is anyone know how to use opencv 3.1 in eclipse ide? (windows 64bit) ive searching for days now and still cant figure out how. Ive tried some methods but when I run the "mingw32-make" i always got errors.

Is anyone know how to use opencv 3.1 in eclipse ide? (windows 64bit) ive searching for days now and still cant figure out how. Ive tried this method (http://cookyourpc.blogspot.com/2015/0...) but when I run the "mingw32-make" part i always got errors.

C:\opencv\sources\modules\core\src\parallel.cpp: In function 'int cv::getThreadNum()': C:\opencv\sources\modules\core\src\parallel.cpp:457:45: error: 'pthread_self' was not declared in this scope return (int)(size_t)(void)pthread_self(); // no zero-based indexing ^ modules\core\CMakeFiles\opencv_core.dir\build.make:965: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj' failed mingw32-make[2]: [modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj] Error 1 CMakeFiles\Makefile2:1468: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed mingw32-make[1]: [modules/core/CMakeFiles/opencv_core.dir/all] Error 2 Makefile:159: recipe for target 'all' failed mingw32-make: ** [all] Error 2

even i apply this

image description