Crop a rectangle using: vector<vector<Point>> squares [closed]

asked 2014-05-18 13:04:52 -0600

updated 2014-05-18 13:18:13 -0600

berak gravatar image

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]

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by StevenPuttemans
close date 2014-05-19 03:20:41.172410

Comments

1
Rect r = boundingRect( squares[i] );
Mat roi = Mat( plate, r );

what went wrong, when you tried it ?

berak gravatar imageberak ( 2014-05-18 13:38:23 -0600 )edit

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

ricardo99 gravatar imagericardo99 ( 2014-05-18 17:55:30 -0600 )edit