OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 25 Aug 2020 13:16:56 -0500result coordinate typehttp://answers.opencv.org/question/234253/result-coordinate-type/ I have been making intersection point calculations between parametric line eqs and planes in opencv. I am using raw imaging point data for the math calculations below. What units of measurement are my results? I haven't done a opencv Rodriquez, transformation or other function on this data set yet, otherwise the question would be settled.
I've also tried "converting" to U, V coordinates but am unsure if its correct.
double numer = plane.get_numer(d, n, Ro); // origin point - p - see diagram
double denom = plane.get_denom(n, Rd);
double t = numer / denom;
Vec3d IP = plane.get_IP(Ro, Rd, t); // IP = 'intersection point'
double U = CV_FX * IP[0] + CV_CX;
double V = CV_FY * IP[1] + CV_CY;
std::cout << "U,V = " << U << "," << V << std::endl;superflyTue, 25 Aug 2020 13:16:56 -0500http://answers.opencv.org/question/234253/How to place one rectangle inside another one without intersections?http://answers.opencv.org/question/181389/how-to-place-one-rectangle-inside-another-one-without-intersections/My JavaFX applications do the follow: opens background image, opens foreground image and foreground image should be placed inside background "randomly" in such way that foreground image should not intersect contour of background image.
Let me show example, where coordinates of foreground image are hardcoded:
![image description](https://i.stack.imgur.com/om74w.png)
So I did the follow: Using snippet from this [question](https://stackoverflow.com/questions/46265726/java-opencv-layer-small-image-onto-larger-image-with-transparency) I combine background image and foreground image into one.
After this I tried to find contour of this combined image using [code](http://androiderstuffs.blogspot.com/2016/06/detecting-rectangle-using-opencv-java.html) from this article. And it looks like OpenCV finds contours of background image successfully.
But I should place foreground image inside background image, adding some random factor in order to foreground can be inside contour in any place and with any rotation factor, but not intersect contour.
If this question or approach are incorrect, sorry, I'm newbie in OpenCV. This code
Imgproc.findContours(gray, contours, new Mat(),
Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
returns ArrayList in contours of such objects
Mat [ 91*1*CV_32SC2, isCont=true, isSubmat=false, nativeObj=0x1cbdcce0, dataAddr=0x1cac3800 ]
and I have no idea how to use it.DrJestonSun, 31 Dec 2017 06:22:52 -0600http://answers.opencv.org/question/181389/Compare segmentation result to ground truthhttp://answers.opencv.org/question/216667/compare-segmentation-result-to-ground-truth/I have some contours which represent certain objects found with `cv2.findContours()` in a segmentation result. On the other hand, I also have the ground truth data in the same format (polygon points in `[x, y]`). I'm now looking for the best way to measure the intersection/overlap of both polygons to measure how well the segmentation performed.
Thank you in advance!
-- Update --
To add in some context, here's for example the data from one contour found with `cv2.findContours()`:
[[[1086 603]],[[1085 605]],[[1078 605]],[[1076 606]],[[1073 606]],[[1071 608]],[[1068 608]],[[1066 610]],[[1065 610]],[[1061 6,3]],[[1060 613]],[[1060 615]],[[1058 616]],[[1058 625]],[[1060 626]],[[1060 636]],[[1061 638]],[[1061 650]],[[1063 651]],[[1063 658]],[[1061 660]],[[1063 661]],[[1063 671]],[[1065 673]],[[1065 676]],[[1066 678]],[[1066 681]],[[1068 683]],[[1068 701]],[[1070 703]],[[1070 713]],[[1075 718]],[[1078 718]],[[1080 720]],[[1101 720]],[[1103 718]],[[1106 718]],[[1110 715]],[[1111 715]],[[1115 711]],[[1116 711]],[[1118 710]],[[1118 708]],[[1120 706]],[[1120 703]],[[1121 701]],[[1121 683]],[[1123 681]],[[1123 670]],[[1121 668]],[[1121 615]],[[1120 613]],[[1120 611]],[[1118 610]],[[1113 610]],[[1111 608]],[[1108 608]],[[1106 606]],[[1103 606]],[[1101 605]],[[1088 605]]]
And this is the ground truth data:
[[1054, 625], [1070, 719], [1084, 726], [1112, 724], [1125, 716], [1126, 631], [1128, 619], [1132, 610], [1127, 603], [1118, 602], [1107, 600], [1090, 600], [1074, 603], [1059, 607], [1049, 614], [1051, 620]]
(Ignore the mismatch of arrays between the contours data and ground truth, this is just an example.)Jérémy KWed, 07 Aug 2019 10:08:34 -0500http://answers.opencv.org/question/216667/Intersection of two imageshttp://answers.opencv.org/question/198456/intersection-of-two-images/I have two images of unequal size -
![image description](/upfiles/1535706090228004.png)
and
![image description](/upfiles/15357061029985736.png)
Is there any way that I can get the intersection of the two images such that the final image is
![image description](/upfiles/1535706136346799.png)
The size of the final image is the same as the size of the ellipse..Maybe pictorally the size doesnt look the same here.
The center of the images coincide.infocloggedFri, 31 Aug 2018 04:03:45 -0500http://answers.opencv.org/question/198456/Detection of contours intersectionshttp://answers.opencv.org/question/103162/detection-of-contours-intersections/I have two contour images and I would like to find the contours intersection. So far I've succesfully used the *logical and* operation, unfortunately I've fallen into this case:
![image description](/upfiles/14750645328121303.jpg)
As you can see, the *logical and* operation is going to fail because there isn't any intersection. If the red contours is in image A, and blue contour is in image B, I would like a way to return the two red pixel indicated by the arrow. Does openCV provide some function to do that? In case there isn't, how would you solve this problem?
PS: the contours come from random shapes, they are NOT straight lines!
Thank you.Davide_sdWed, 28 Sep 2016 07:15:34 -0500http://answers.opencv.org/question/103162/find if line and polygon are intersecting in java opencvhttp://answers.opencv.org/question/97124/find-if-line-and-polygon-are-intersecting-in-java-opencv/I need help in opencv java.
Is there any java api that finds if a line and polygon are intersecting?
It would be very helpful if anyone could answer this asap. thanks in Advance.
IndiraWed, 22 Jun 2016 20:50:25 -0500http://answers.opencv.org/question/97124/Intersection of centroid and line/rectanglehttp://answers.opencv.org/question/93209/intersection-of-centroid-and-linerectangle/ I'm currently making a traffic count system using opencv and python and what I exactly intend to do is that,to increment the counter as soon as the centroid of the blob passes or crosses a line or a small rectangle. My question is how to do this as I don't know how to implement cv2.lines or cv2.rectangle in this. Please see this video and if anybody could tell how exactly the intersection or counting is working in this video: https://www.youtube.com/watch?v=z1Cvn3_4yGo
Thanks in advance.kartikTue, 19 Apr 2016 13:43:53 -0500http://answers.opencv.org/question/93209/how to find coordinates of intersection of lines after using "houghlines"http://answers.opencv.org/question/92164/how-to-find-coordinates-of-intersection-of-lines-after-using-houghlines/ Hello dears,
![image description](/upfiles/14600231185310187.png)
As you can see,i would like to find the coordinates of lines,but unfortunately i could not do it.
i used this code for drawing the lines:
Canny(result , can , 50 , 200 , 3);
imshow("can",can);
vector<Vec2f> lines;
HoughLines(can,lines ,1,CV_PI/180,75,0,0);
for( size_t i = 0; i < lines.size(); i++ )
{
float rho = lines[i][0], theta = lines[i][1];
Point pt1, pt2;
double a = cos(theta), b = sin(theta);
double x0 = a*rho, y0 = b*rho;
pt1.x = cvRound(x0 + 1000*(-b));
pt1.y = cvRound(y0 + 1000*(a));
pt2.x = cvRound(x0 - 1000*(-b));
pt2.y = cvRound(y0 - 1000*(a));
line( can, pt1, pt2, Scalar(255), 2, CV_AA);
}
cvtColor(can,can,CV_GRAY2RGB);
imshow("cdst",can);
in continue, i do not know how i can find the coordinate.Please help me,thank you.
Best,
ArasharashThu, 07 Apr 2016 05:04:23 -0500http://answers.opencv.org/question/92164/Finding intersections of objects in a single contourhttp://answers.opencv.org/question/86657/finding-intersections-of-objects-in-a-single-contour/ Hello,
I have an image of leaves (seen from above) that can partly recover each other.
http://img11.hostingpics.net/pics/793244img2.jpg
I found the contour of the image (in red on the image) and what I want to do now is to find where two leaves intersect. What I've done so far is to:
- consider a point with index i in the contour c, say c[i], which has two coordinates x and y,
- compute the angle of the vector (c[i-1], c[i]) with the half line (x > 0), which I denote ang[i], this returns an angle between 0 and 360,
- do the previous step for the B angles ang[i], ang[i-1], ang[i-2] and average the result, this gives me the mean direction *before* c[i],
- do the same for the B angles ang[i+1], ang[i+2], ang[i+3], etc. and average the result, this gives me the mean direction *after* c[i],
- flag (in blue on the image) c[i] as a potential intersection if the difference between the mean direction after and before is greater than a deviation angle D.
I've tried many values of B and D, but due to the different natures of the intersections between leaves, I never manage to recover them all, and uniquely them. Here is an example of output:
http://img11.hostingpics.net/pics/381717fillednewedge6130J21C1S179Sha.jpg
Is something wrong with the method I tried?
Is there any other approach less naive and more robust I could try?
Many thanks.PlapPlopThu, 04 Feb 2016 11:44:32 -0600http://answers.opencv.org/question/86657/how can I find the coordinates with the given step?http://answers.opencv.org/question/76844/how-can-i-find-the-coordinates-with-the-given-step/ I have the following picture from camera:
http://www.pictureshack.ru/images/10081_3.jpg
I need: http://www.pictureshack.ru/images/643_2.jpg
I tried first to find the lines with HoughLines , but results were not good races :
http://www.pictureshack.ru/done_66361_4.jpg
then, I considered myself as I can see the laser line . I've tried using Canny , there are too many other unnecessary lines . After that I read on the internet about HSV . as firstly I made trackable:
int iLowH = 0;
int iHighH = 255;
int iLowS = 0;
int iHighS = 255;
int iLowV = 0;
int iHighV = 255;
//Create trackbars
cvCreateTrackbar("LowH", "Control", &iLowH, 255);
cvCreateTrackbar("HighH", "Control", &iHighH, 255);
cvCreateTrackbar("LowS", "Control", &iLowS, 255);
cvCreateTrackbar("HighS", "Control", &iHighS, 255);
cvCreateTrackbar("LowV", "Control", &iLowV, 255);
cvCreateTrackbar("HighV", "Control", &iHighV, 255);
as the next I have with findcountors that Countor have found:
vector<vector<Point> > contours;
vector<Point> contour;
findContours( imgThresholded, contours, CV_RETR_TREE, CV_CHAIN_APPROX_NONE );
//findContours( edges, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE );
for ( size_t i = 0; i < contours.size(); i++)
{drawContours(imgOriginal,contours,i,color);}
und I have :
http://www.pictureshack.ru/images/75086_2.jpg
How do I find the coordinates at the intersection of the lines drawn by me and " lines " in the picture?
MValeriyFri, 20 Nov 2015 05:46:05 -0600http://answers.opencv.org/question/76844/cv::rotatedRectangleIntersection assertion failed.http://answers.opencv.org/question/74697/cvrotatedrectangleintersection-assertion-failed/Hi,
I'm working on finding the intersections between two rotatedRectangle.
RotatedRect r1 = RotatedRect(Point2f(1174.85852, 730.577332), Size2f(1318.08118, 400.503601), -2.31209111);
RotatedRect r2 = RotatedRect(Point2f(1172.80396, 728.535950), Size2f(1318.74963, 389.407377), -2.97718263);
vector<cv::Point2f> vertices;
int intersectionType = cv::rotatedRectangleIntersection(r1, r2, vertices);
then it throws this: OpenCV Error: Assertion failed (intersection.size() <= 8) in cv::rotatedRectangleIntersection, file ......, line 245 even if the verticies.size() is 6.
Strange thing is, it works fine in Debug mode, but it doesn't in Release mode...
Can anyone help me?
Thanks in advance.
movedThu, 29 Oct 2015 16:09:03 -0500http://answers.opencv.org/question/74697/How to find if 2 rectangles are overlapping each otherhttp://answers.opencv.org/question/67091/how-to-find-if-2-rectangles-are-overlapping-each-other/ Hello Forum,
For the following image below, how do i determine if the smaller rectangle is overlapped / partially overlapped with the larger one ? I have their coordinates in frame i.e. rect.x and rect.y.
Should I just use FLANN or Nearest Neighbour or is there a better way ? http://docs.opencv.org/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.html
![image description](/upfiles/14379860499787797.png)NbbMon, 27 Jul 2015 03:36:14 -0500http://answers.opencv.org/question/67091/How to compute intersections of two contourshttp://answers.opencv.org/question/37392/how-to-compute-intersections-of-two-contours/I have 2 contours and I want to compare how much the same are they, as the ratio of the `area_of_c1/area_of_intersection` and `area_of_c2/area_of_intersection`. I have done in a way of creating 2 convex contours and 2 `Mat`s of zeros and fill them with `fillConvexPoly()` and doing a `bitwise_and()` between the two `Mat`s for getting the intersection. Then I have counting the non zeros pixels for getting the areas and computed the ratios. Is there another more efficient way of computing the two ratios (like computing the intersection of two contours, or I do not know)?thdrksdfthmnThu, 17 Jul 2014 03:28:19 -0500http://answers.opencv.org/question/37392/How to find the intersection point of two lineshttp://answers.opencv.org/question/9511/how-to-find-the-intersection-point-of-two-lines/
hi,
i tried the HoughLines tutorial to detect the lines of a image. Now i want to find the intersection points between detected lines. Is there any in built function in opencv for this. If not can any one suggest a way how to get the line intersections in opencv? (with simple example if possible) plz help.Heshan SandeepaMon, 18 Mar 2013 05:15:02 -0500http://answers.opencv.org/question/9511/