I am using open CV,in IOS. I already detected the boundary of the paper sheet in an Image as show in image and , Now I have to drag these boundary line on touch for adjusting the crop frame. how we can adjust boundary line and how we can crop image inside the boundary?
This is possible in openCV or I use openGL for this?
@moosgummi : I call your method in below method
- (cv::Mat)finshWork:(cv::Mat &)image
{
Mat img0 =image;
Mat img1;
cvtColor(img0, img1, CV_RGB2GRAY);
// apply your filter
Canny(img1, img1, 100, 200);
// find the contours
vector< vector<cv::Point> > contours;
findContours(img1, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
// you could also reuse img1 here
Mat mask = Mat::zeros(img1.rows, img1.cols, CV_8UC1);
// CV_FILLED fills the connected components found
drawContours(mask, contours, -1, Scalar(255), CV_FILLED);
// let's create a new image now
Mat crop(img0.rows, img0.cols, CV_8UC3);
// set background to green
crop.setTo(Scalar(0,255,0));
// and copy the magic apple
img0.copyTo(crop, mask);
// normalize so imwrite(...)/imshow(...) shows the mask correctly!
normalize(mask.clone(), mask, 0.0, 255.0, CV_MINMAX, CV_8UC1);
std::vector<cv::Point> biggestContour = contours[contours.size()-1];
NSLog(@"%d",biggestContour[0].x);
NSLog(@"%d",biggestContour[0].y);
cv::Mat paperImage =[self getPaperAreaFromImage:image:biggestContour];
//return crop;
return paperImage;
}
Thanks All