find and save the coordinates
The idea draw the line and find the point of intersection. I want to ask the first line to find the coordinates (x, y) and store them in a variable. then indented 5 pixel coordinates check again if the coordinates on the Y axis are the same check again until the Y is not greater than the initial stuns Y. save the coordinates, and then find the coordinates 50 and 200 pixels. then find the point where the Y coordinate again become equal to the initial value again and save it as a variable. the screen must be vyvezheny 1) the coordinates of the first line, 2) where Y is greater than nachalngoy 3-4) coordinates 50 and 200 pixels and 5) when Y again becomes equal to the original. 5 different points
I have the following code:
int main(int argc, char** argv)
{
Mat src,cdst;
src = imread("2.jpg");
if(src.empty())
{return -1;}
cvtColor(src, cdst, CV_BGR2GRAY);
vector<Rect> rects_of_lines;
Rect rect_of_line;
rect_of_line.x = 1;
rect_of_line.y = 0;
rect_of_line.width = 1;
rect_of_line.height = src.rows;
rects_of_lines.push_back( rect_of_line );
rectangle( src, rect_of_line, Scalar(0,0,255));
vector<vector<Point> > contours;
findContours(cdst.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
Rect _boundingRect;
for (size_t i = 0; i < contours.size(); ++i)
{
if( contourArea( contours[i] ) > 20 )
{
_boundingRect = boundingRect( Mat(contours[i]) );
for( int j = 0; j < rects_of_lines.size(); j++ )
{
Rect intersection = _boundingRect & rects_of_lines[j];
if(intersection.height > 0)
{
intersection.x = intersection.x + (intersection.width / 2 );
intersection.y = intersection.y + (intersection.height / 2 );
intersection.width = 1;
intersection.height = 1;
rectangle( src, intersection, Scalar(255,0,0),10);
putText(src, format("x = %d , y = %d",intersection.x,intersection.y),Point(intersection.x,intersection.y),CV_FONT_HERSHEY_COMPLEX,0.5,Scalar(255,255,255));
} } } }
imshow("1", src);
waitKey();
return 0;
}
and folowing pictures
I have : http://www.pictureshack.ru/images/946... i need : http://www.pictureshack.ru/images/400...
Could you please avoid to much simoultaneous questions like this one?