0

I have two related problems and have tried the suggestions given to similar problems and have not been able to resolve them.

First of all, what I'm trying to do is to draw circles for key points that I keep as floating numbers in two separate NumPy arrays for the h and v coordinates on an image. For this purpose, I use the code snippet I have specified below(H for horizontal, V for vertical):

    for h, v in zip(H.astype(int), V.astype(int)):
        color = choose_random_color(seed)
        image_withkeys = cv2.circle(image_withkeys, (h, v), 10, color, -1, cv2.LINE_AA)

where image_withkeys is just the copy of the initial image, H and V are horizontal and vertical positions as floating number NumPy arrays respectively.

When I want to run the code as it is, I get the following error:

cv2.error: OpenCV(4.5.4) :-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

As can be seen in the error text, I am using 4.5.4 as the cv2 version. In one of the posts I've seen someone said:

Because opencv 4.5.2 has made a backwards-incompatible change without bumping their major version. This would break with your existing code. Try opencv 4.1.1

You can see the whole tread here.

Is there a way to set the cv2 version on a different version that will support the code I wrote? Or should I use a different method for integer casting? I am open to any suggestions.

Thanks in advance.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
mergen
  • 38
  • 8
  • error _means to say_ that it wants integers. in older versions, it must be **python** integers, not numpy integers. `center=(int(x), int(y))`. newer versions are more tolerant and accept numpy integers and even numpy arrays (instead of only tuples/lists). -- you can't just "set the version". you can upgrade/downgrade the `opencv-python` package. – Christoph Rackwitz Apr 01 '22 at 08:22
  • also, that dude in the link is mistaken. – Christoph Rackwitz Apr 01 '22 at 08:27

0 Answers0