Ask Your Question

ricardo99's profile - activity

2019-12-29 20:21:28 -0600 received badge  Popular Question (source)
2018-03-03 14:56:24 -0600 received badge  Popular Question (source)
2015-03-23 05:54:16 -0600 received badge  Student (source)
2014-11-09 01:58:23 -0600 received badge  Taxonomist
2014-06-20 14:45:06 -0600 commented answer how to Build and install cvBlobsLib?

But I want use cvBlobsLib on Windows 7, What I do Now?

2014-06-20 14:24:54 -0600 commented answer how to Build and install cvBlobsLib?

Hello @unuxnut, thanks for your answer, I'm trying to use "cvBlobsLib" because uses cv::Mat and is newer, in this moment I found this links: http://www.eng.auburn.edu/~troppel/internal/sparc/TourBot/TourBot%20References/cvdocuments/cvBlobsLib.html http://stackoverflow.com/questions/7723206/integrating-cvblobslib-in-opencv and when Build show this error: Error 4 error C1083: Cannot open include file: 'pthread.h': No such file or directory c:\users\ricardo\documents\visual studio 2013\projects\cvblobslib\cvblobslib\ComponentLabeling.h 10 1 cvBlobsLib And I serch and pthread.h doesn't exist in/for windows

2014-06-20 12:13:10 -0600 commented answer good algorithm to background subtraction for a car tracking?

Because in this way I don't update the background and I don't know if exist another way with best results and performance.

2014-06-19 16:43:26 -0600 received badge  Critic (source)
2014-06-19 16:42:22 -0600 received badge  Autobiographer
2014-06-19 14:39:35 -0600 answered a question Is Studio necessary?

No but is better "for me" How to install Opencv 2.4.8 on VS2012: https://www.youtube.com/watch?v=v-VgWxkVp2w

2014-06-19 14:35:38 -0600 received badge  Supporter (source)
2014-06-19 14:34:50 -0600 commented answer how to Build and install cvBlobsLib?

Hello @unxnut, thanks for your answer, you can teach step by step? I download and extract (2 folders: example, library, 6 ather files)

2014-06-19 14:27:09 -0600 answered a question How do I Create a Mat structure in C++, from the image file data received from Java Code?
2014-06-19 12:18:02 -0600 commented answer good algorithm to background subtraction for a car tracking?

I added and modified these lines and had a good result if someone know another way to solve this problem, tell us.

//bg.getBackgroundImage(back); cv::Mat element = getStructuringElement(MORPH_RECT, Size(3, 3), Point(1, 1)); cv::erode(fore, fore, element); element = getStructuringElement(MORPH_RECT, Size(9, 9), Point(4, 4)); cv::dilate(fore, fore, element);

2014-06-18 17:25:01 -0600 asked a question how to Build and install cvBlobsLib?

Hi all, I want to use cvBlobsLib in my project on Visual studio 2013 but I didn't found any tutorial or another material about build and install in a project C++/OpenCV/Visual Studio 2013, if anyone knows how to share with the community. Thanks!

2014-06-18 12:53:28 -0600 commented answer good algorithm to background subtraction for a car tracking?

has the same result

2014-06-18 09:52:53 -0600 asked a question good algorithm to background subtraction for a car tracking?

Actually I'm using "gaussian mixture based" "BackgroundSubtractorMOG2" to tracking cars in a video, but the result is a video in slowmotion and noise like car shadow. if someone know another algorithm with better performance, please answers me. this is the code:

cv::Mat frame;
cv::Mat back;
cv::Mat fore;
cv::VideoCapture cap("CarSurveillance/Video1.avi");
cv::BackgroundSubtractorMOG2 bg;
bg.setInt("nmixtures", 3);
bg.setBool("detectShadows", false);

std::vector<std::vector<cv::Point> > contours;

cv::namedWindow("Frame");
cv::namedWindow("Background");

while (1)
{
    cap.read(frame);
    bg.operator ()(frame, fore);
    bg.getBackgroundImage(back);
    cv::erode(fore, fore, cv::Mat());
    cv::dilate(fore, fore, cv::Mat());
    cv::findContours(fore, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    cv::drawContours(frame, contours, -1, cv::Scalar(0, 0, 255), 2);
    cv::imshow("Frame", frame);
    cv::imshow("Background", back);
    if (cv::waitKey(30) >= 0) break;
}
return 0;

I changed these lines:

//bg.getBackgroundImage(back); 
cv::Mat element = getStructuringElement(MORPH_RECT, Size(3, 3), Point(1, 1));
cv::erode(fore, fore, element); 
element = getStructuringElement(MORPH_RECT, Size(9, 9), Point(4, 4)); 
cv::dilate(fore, fore, element);
2014-06-16 11:08:43 -0600 commented answer How do I display two or more videos using opencv?

Hello @unxnut, Thank you very much for your help.

2014-06-16 11:04:30 -0600 received badge  Scholar (source)
2014-06-14 18:43:07 -0600 commented answer How do I display two or more videos using opencv?

other informations: Win 7 64 bits, opencv 2.4.8, Visual studio 2013 with update 2

2014-06-14 17:45:55 -0600 commented answer How do I display two or more videos using opencv?

the same, my videos have 2.5MB and 2.2MB

2014-06-14 17:25:26 -0600 commented answer How do I display two or more videos using opencv?

Still, in your test worked perfectly?

2014-06-14 17:03:16 -0600 commented answer How do I display two or more videos using opencv?

after reading a frame and it shows I check the next frame if you have not I make video2WindowDestroyed = true then next time do not enter in the first block if (&& if first is false will not read the (cap.read (frame) == true ))

2014-06-14 15:11:53 -0600 commented answer How do I display two or more videos using opencv?

Hello @unxnut Now I'm using flags, but now I have a smaller Problem!

2014-06-13 12:17:35 -0600 asked a question How do I display two or more videos using opencv?

How do I display two or more videos with different lenghts (1,2 mins) using opencv?

int main(){

/* Open the Video File for Reading */
VideoCapture cap("CarSurveillance/Video1.avi"); // 00:00:33
VideoCapture cap2("CarSurveillance/Video2.mp4"); // 00:01:12

if (!cap.isOpened()){
    cout << "Was not possible to Open the Video" << endl;
    cout << "Reasons:" << endl;
    cout << "1st: Wrong PATH" << endl;
    cout << "2nd: Wrong Extension" << endl;
    cout << "3rt: Unknown Reasons" << endl;
    system("PAUSE");
    exit(EXIT_FAILURE);
}
if (!cap2.isOpened()){
    cout << "Was not possible to Open the Video" << endl;
    cout << "Reasons:" << endl;
    cout << "1st: Wrong PATH" << endl;
    cout << "2nd: Wrong Extension" << endl;
    cout << "3rt: Unknown Reasons" << endl;
    system("PAUSE");
    exit(EXIT_FAILURE);
}
namedWindow("Video1", CV_WINDOW_AUTOSIZE); 
bool video1WindowDestroyed = false;
bool video2WindowDestroyed = false;
namedWindow("Video2", CV_WINDOW_AUTOSIZE);
double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Video 1 Frame per seconds : " << fps << endl;
fps = cap2.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Video 2 Frame per seconds : " << fps << endl;
Mat frame, frame2;
cap.read(frame); // read a new frame from video
cap2.read(frame); // read a new frame from video

while (true){

    if ((video1WindowDestroyed == false) && (cap.read(frame) == true)){
        imshow("Video1", frame);
        if (cap.read(frame) == false){
            destroyWindow("Video1");
            video1WindowDestroyed = true;
        }
    }
    if ((video2WindowDestroyed == false) && (cap2.read(frame2) == true)){
        imshow("Video2", frame2);
        if (cap2.read(frame2) == false){
            destroyWindow("Video2");
            video2WindowDestroyed = true;
        }
    }

    if (video2WindowDestroyed == true && video2WindowDestroyed == true){
        break;
    }
    waitKey(30);
}
waitKey(0);
system("PAUSE");
return 0;

}

when first video ends he is slow to close the window and pause the second video, two seconds after restart

2014-06-12 13:06:40 -0600 received badge  Editor (source)
2014-06-12 12:13:00 -0600 commented answer How I can clean the noise in this Plate?

I tried it but didn't work, I've tried to answer my question with the code but I need two days for do it.

2014-06-12 09:43:21 -0600 asked a question How I can clean the noise in this Plate?

How can I clean the noise in the Plate leaving only the characters?image description

2014-06-12 09:33:03 -0600 asked a question how I correct the perspective?

how do I correct the perspective and keeping the aspect ratio of a car plate? this is the code:

Mat src = imread(path);
Mat thr;
cvtColor(src, thr, CV_BGR2GRAY);
threshold(thr, thr, 70, 255, CV_THRESH_BINARY);

vector< vector <Point> > contours; // Vector for storing contour
vector< Vec4i > hierarchy;
int largest_contour_index = 0;
int largest_area = 0;

Mat dst(src.rows, src.cols, CV_8UC1, Scalar::all(0)); //create destination image
findContours(thr.clone(), contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); // Find the contours in the image
for (int i = 0; i< contours.size(); i++){
    double a = contourArea(contours[i], false);  //  Find the area of contour
    if (a>largest_area){
        largest_area = a;
        largest_contour_index = i;                //Store the index of largest contour
    }
}

drawContours(dst, contours, largest_contour_index, Scalar(255, 255, 255), CV_FILLED, 8, hierarchy);
vector<vector<Point> > contours_poly(1);
approxPolyDP(Mat(contours[largest_contour_index]), contours_poly[0], 5, true);
Rect boundRect = boundingRect(contours[largest_contour_index]);

if (contours_poly[0].size() == 4){
    std::vector<Point2f> quad_pts;
    std::vector<Point2f> squre_pts;
    quad_pts.push_back(Point2f(contours_poly[0][0].x, contours_poly[0][0].y));
    quad_pts.push_back(Point2f(contours_poly[0][1].x, contours_poly[0][1].y));
    quad_pts.push_back(Point2f(contours_poly[0][3].x, contours_poly[0][3].y));
    quad_pts.push_back(Point2f(contours_poly[0][2].x, contours_poly[0][2].y));

    squre_pts.push_back(Point2f(boundRect.x, boundRect.y));
    squre_pts.push_back(Point2f(boundRect.x, boundRect.y + boundRect.height));
    squre_pts.push_back(Point2f(boundRect.x + boundRect.width, boundRect.y));
    squre_pts.push_back(Point2f(boundRect.x + boundRect.width, boundRect.y + boundRect.height));

    Mat transmtx = getPerspectiveTransform(quad_pts, squre_pts);
    Mat transformed = Mat::zeros(src.rows, src.cols, CV_8UC3);
    warpPerspective(src, transformed, transmtx, src.size());
    Point P1 = contours_poly[0][0];
    Point P2 = contours_poly[0][1];
    Point P3 = contours_poly[0][2];
    Point P4 = contours_poly[0][3];


    line(src, P1, P2, Scalar(0, 0, 255), 1, CV_AA, 0);
    line(src, P2, P3, Scalar(0, 0, 255), 1, CV_AA, 0);
    line(src, P3, P4, Scalar(0, 0, 255), 1, CV_AA, 0);
    line(src, P4, P1, Scalar(0, 0, 255), 1, CV_AA, 0);
    rectangle(src, boundRect, Scalar(0, 255, 0), 1, 8, 0);
    rectangle(transformed, boundRect, Scalar(0, 255, 0), 1, 8, 0);

    imshow("quadrilateral", transformed);
    imshow("thr", thr);
    imshow("dst", dst);
    imshow("src", src);
    waitKey();
}
else
    cout << "Make sure that your are getting 4 corner using approxPolyDP..." << endl;

these are the images original and result image description image description

How I keep the aspect ratio?

2014-05-18 17:55:30 -0600 commented question Crop a rectangle using: vector<vector<Point>> squares

thank you very much berak, I tried but not used boundingRect (). ,this is the first time I see THANK YOU

2014-05-18 13:04:52 -0600 asked a question Crop a rectangle using: vector<vector<Point>> squares

I have a code that draws a square drive plate and would use it if it were possible to make a cut in the image storing the car plate in another image, if possible, how do I? I already tried using ROI

the code:

void Process::drawSquares(char* adress, vector<vector<Point>>& squares){
    Mat plate = imread(adress, CV_LOAD_IMAGE_COLOR);
    for( size_t i = 0; i < squares.size(); i++ ){
        const Point* p = &squares[i][0];
        int n = (int)squares[i].size();
        polylines(plate, &p, &n, 1, true, Scalar(0,255,0), 3, CV_AA);
    }
    imshow("Plate", plate);
    waitKey(0);
}

vector<vector<point>>& squares is a vector that stores several square but the this time I store only one square: plate of the car (I want make the cut)

I tried used ROI but but I could not make it work. for more details of my project as a whole. My emails: [email protected] / [email protected]