Skip to content

Add diagonal corner lines for better visibility - #1

Open
kanawanaikoto wants to merge 1 commit into
hassanrrraza:mainfrom
kanawanaikoto:fix
Open

Add diagonal corner lines for better visibility#1
kanawanaikoto wants to merge 1 commit into
hassanrrraza:mainfrom
kanawanaikoto:fix

Conversation

@kanawanaikoto

Copy link
Copy Markdown

Modify some function parameters to achieve this.
Original code appears to be invalid redundant code.

corner_length = min(20, w // 4, h // 4)

cv2.line(frame, (x1, y1), (x1 + corner_length, y1), color, thickness)
cv2.line(frame, (x1, y1), (x1, y1 + corner_length), color, thickness)

cv2.line(frame, (x1 + w, y1), (x1 + w - corner_length, y1), color, thickness)
cv2.line(frame, (x1 + w, y1), (x1 + w, y1 + corner_length), color, thickness)

cv2.line(frame, (x1, y1 + h), (x1 + corner_length, y1 + h), color, thickness)
cv2.line(frame, (x1, y1 + h), (x1, y1 + h - corner_length), color, thickness)

cv2.line(frame, (x1 + w, y1 + h), (x1 + w - corner_length, y1 + h), color, thickness)
cv2.line(frame, (x1 + w, y1 + h), (x1 + w, y1 + h - corner_length), color, thickness)

The deletion of the code above does not affect the realization of the original effect
Before
屏幕截图 2025-05-31 004917

After
屏幕截图 2025-05-31 013920
I have taken note of your comment and made some modifications.

To make the invalid redundant code meaningful

@hassanrrraza hassanrrraza left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!
However, this version introduces arbitrary +2 and -2 offsets, which may cause the corner lines to look misaligned, especially on smaller bounding boxes. It also adds unnecessary complexity to otherwise clean and precise drawing logic.

That said, this approach might be useful in specific cases, such as:
-Creating visual separation from the bounding box edges
-Applying anti-aliasing or avoiding overlap with other UI elements
-Performing pixel-level tuning for aesthetic reasons

Unless we have a strong visual requirement for such tweaks, I recommend keeping the original version for consistency and clarity.

@kanawanaikoto

Copy link
Copy Markdown
Author

Thank you for your response. I understand your intention, but in this case, the following code seems to be redundant.

corner_length = min(20, w // 4, h // 4)

cv2.line(frame, (x1, y1), (x1 + corner_length, y1), color, thickness)
cv2.line(frame, (x1, y1), (x1, y1 + corner_length), color, thickness)

cv2.line(frame, (x1 + w, y1), (x1 + w - corner_length, y1), color, thickness)
cv2.line(frame, (x1 + w, y1), (x1 + w, y1 + corner_length), color, thickness)

cv2.line(frame, (x1, y1 + h), (x1 + corner_length, y1 + h), color, thickness)
cv2.line(frame, (x1, y1 + h), (x1, y1 + h - corner_length), color, thickness)

cv2.line(frame, (x1 + w, y1 + h), (x1 + w - corner_length, y1 + h), color, thickness)
cv2.line(frame, (x1 + w, y1 + h), (x1 + w, y1 + h - corner_length), color, thickness)

When drawing the detection box, you used thickness=1, and when drawing the lines, you still used thickness=1. Since these two parts overlap, the final line width remains thickness=1, making the corner lines appear unnecessary.
Before Delete
屏幕截图 2025-05-31 004917
After deletion
屏幕截图 2025-05-31 141936
At least on my device, it doesn't seem to make a difference.
Can this code be deleted, or is there a specific purpose for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants