New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cv::line thickness 0 not supported #10598
Comments
@alalek I would like to try and fix this issue. I replicated the issue, and I found that the thickness '0' line is same as thickness '1' line. |
I believe we should raise an error in case of 0 value instead of disabling of line drawing. "Empty" drawing hides wrong unexpected behavior like |
@alalek are we fixing this issue? I'm only a little more than a beginner in open source, so could you be a bit more elborate? |
@Riyuzakii Yes, the issue should be fixed. @alalek described the expected behavior of the function in case 0 is passed for |
I just wanted to note, that in my opinion allowing thickness 0 (but not drawing) is useful. In my case i was drawing lines from a list with associated line types and per type parameters. I disable a line type by setting its thickness to 0. my current workaround is a proxy method with a test. imo the parameter type (int) already documents the lack of support for floating point thicknesses and i'd say that most programmers are aware of loosing the decimal part in int division or conversion. at least inkscape (as an analogy) also allows to set a line thickness of 0 and doesn't draw it in that case. |
@terfendail where should I start looking to fix this error, I mean the files. |
line drawing function is implemented in |
@damdamce I think processing of 0 thickness as if we really try to draw invisible line is strange from performance point of view. So anyway the fix should be to check whether the thickness is 0 at the very beginning of the function and do something in that case. The action could be do nothing or throw an exception. The latter case require a tiny check at callers side but could help to avoid unintended 0 thickness drawing. |
@terfendail @alalek
|
@Riyuzakii |
@terfendail Sorry for the late reply, I got a bit side tracked because of exams. I've never written test before so I'm having a bit of hard time writing them, can you point me to some resource where I can learn about testing a bit? |
@Riyuzakii OpenCV test system is based on GoogleTest. You could read this to get some basic understanding. Also there are existing tests at |
@terfendail I went through the link you gave. here are the changes that i have done. they don't match with what you suggested earlier but I have done them by looking at other examples and google test documentation.
What i'm trying to do is, make a line with zero thickness and if the matrix has cnt not equal to zero the raise a fatal-error. because cnt should be zero if the line doesn't exist! |
As discussed earlier the error should be raised by the |
If we have already raised an error before ASSERT_EQ with this ASSERT_THROW(line(...),cv::Exception) |
ASSERT_EQ could check that error is raised prior to output image modification, but IMHO ASSERT_EQ isn't necessary here |
@terfendail Please have a look and suggest changes, I know they might be needed! |
cv::line can only draw lines with an thickness of at least 1 as far as I can see from drawing.cpp (method ThickLine).
I tried to disable line drawing by setting the thickness to 0, but in vain. This should be either supported or at least documented, imo.
Thanks for the great lib anyways :)
The text was updated successfully, but these errors were encountered: