Skip to content

unexplainable reversal of y coordinate in numpy image array #15406

@nyck33

Description

@nyck33
System information (version)
  • OpenCV => 4.1.0 (opencv-contrib-python)
  • Operating System / Platform => Ubuntu 18
  • Compiler => VSCode
Detailed description

The rows are getting switched when I assign them to variables.
cv2.rectangle() requires top left then bottom right so I know which ones these are in my bbox[] list and can draw the rectangle. However when I try to use the same coordinates for slicing, my y's (which I assigned y1 = bbox[3], y2=bbox[1] are reversed with y1 being a larger integer than y2 so I have to slice using y2:y1 instead. I am pretty sure that I printed out bbox[] 0 to 3 as well and it was the same so not sure why those coordinates work for both cv2.rectange() and plt.Rectangle() but then not for slicing in this case.
I posted on datasciencestackexchange about it: https://datascience.stackexchange.com/questions/58308/unexplainable-reversal-of-x-y-coordinates-in-numpy-image-array?noredirect=1#comment63897_58308

Steps to reproduce

python code, please look at cv2.rectangle() at the bottom of the function so you know what top left and bottom of bbox are:

Metadata

Metadata

Assignees

No one assigned

    Labels

    incompletequestion (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.org

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions