Drawing an arc
Hi guys, I have arc parameters from Autocad file and I need to draw it using opencv. However, using corresponding parameters in cv::ellipse function the arc is absolutely not the same as in Autocad. Here is my code:
cv::ellipse(image, center, cv::Size(radius, radius), angle, start_angle, end_angle, cv::Scalar(255, 255, 255));
The picture should be like
but in fact I've got
Here is parameters for every arc:
1) center.x = 495.419403
center.y = 527.065674
start angle = 0.0000
end abgle = 56.88228
full angle = 56.88228
start.x = 501.41940
start.y = 527.06567
end.x = 498.69757
end.y = 532.090979
arc_center.x = 500.695245
arc_center.y = 529.92321
radius = 6.00000
2) center.x = 495.4194
center.y = 486.31543
start angle = 270.0000
end abgle = 0.0000
full angle = 90.0000
start.x = 495.41940
start.y = 480.31543
end.x = 501.4194
end.y = 486.31543
arc_center.x = 499.6620
arc_center.y = 482.07279
radius = 6.00000
3) center.x = 454.6691
center.y = 486.31543
start angle = 213.11771
end abgle = 270.000
full angle = 56.88228
start.x = 449.64386
start.y = 483.03727
end.x = 454.66916
end.y = 480.31543
arc_center.x = 451.8116
arc_center.y = 481.03959
radius = 6.00000
4) center.x = 419.4194
center.y = 562.31543
start angle = 56.88228
end abgle = 213.1177
full angle = 156.2354
start.x = 429.2539
start.y = 577.3913
end.x = 404.3435
end.y = 552.4809415
arc_center.x = 406.69148
arc_center.y = 575.04336
radius = 18.00000
How can I draw correct arcs? I've got start and end points of the arc, radius, and center points (arc center and center from where radius goes)
could you post whole code you tried. or values you get from autocad
Seems like you're not passing the right start and end angles. Can you calculate those angles in AutoCAD ?
I updated my post with required info. Looks like the problem might be somewhere in that, that autocad coordinates start from left bottom corner while in openCV from left top corner. I changed Y value in every point to (H - autocad_point.y). Now the image has correct rotation, but still problems with arcs. Here is what I got now: picture
As @sturkmen asked, provide code please so that we can debug it locally. Could it be a radians/degrees issue?
Degrees. I can't provide full code because it uses 3rd partylibraries to work with autocad file. So you won't be able to compile this code. I just can provide coordinatess of all the primitives for you to try to draw them. I can provide autocad file as well.