Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Minor Bug: PointsVisualizer() throws error when passed floating coordinate values #5249

Open
soumya997 opened this issue Apr 3, 2024 · 0 comments

Comments

@soumya997
Copy link

soumya997 commented Apr 3, 2024

  1. Issue:
    I can't share my code but below is a minimal code sample to reproduce the error. My code calls the function DensePoseDataPointsVisualizer() and internally it calls PointsVisualizer(), at the 108 line cv2.circle() gets called, but as the centre coordinates passed in that function is in float, cv2 throws an error, as cv2.circle() expects integer pixel coordinates as centre.

Here is the google colab notebbok that reproduces the error.

height, width = 400, 400
radius = 50
image = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
centers = [(100.09, 100.5), (300.6, 300.89)]

viz_func = PointsVisualizer()
viz_func.visualize(image, centers)
  1. Error Log:
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
[<ipython-input-3-fe6e38084d89>](https://localhost:8080/#) in <cell line: 2>()
      1 viz_func = PointsVisualizer()
----> 2 viz_func.visualize(image, centers)

[/content/detectron2/projects/DensePose/densepose/vis/base.py](https://localhost:8080/#) in visualize(self, image_bgr, pts_xy, colors_bgr, rs)
    106             color_bgr = colors_bgr[j] if colors_bgr is not None else self.color_bgr
    107             r = rs[j] if rs is not None else self.r
--> 108             cv2.circle(image_bgr, (x, y), r, color_bgr, -1)
    109         return image_bgr
    110 

error: OpenCV(4.8.0) :-1: error: (-5:Bad argument) in function 'circle'
> Overload resolution failed:
>  - Can't parse 'center'. Sequence item with index 0 has a wrong type
>  - Can't parse 'center'. Sequence item with index 0 has a wrong type
  1. Changes Made:
    changed,
    x, y = pt_xy
    to
    x, y = [int(val) for val in pt_xy]

https://github.com/soumya997/detectron2/blob/somusan-fixes/projects/DensePose/densepose/vis/base.py#L95C1-L109C25

  1. output of git rev-parse HEAD; git diff
    0f3f9920d3e98e4db7442c19262d5f0eade25581
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

No branches or pull requests

1 participant