python - OpenCV overwrites my original image when drawing a line with cv2.line(...) -
i'm using cv2.line(...)
draw lines on existing image. i've broken down simple example. don't understand why original image lost on first call cv2.line(...)
, same doesn't appear happen on second call.
# show original image (bgr color map) misc.imshow(vis) # draw first line display, original image lost cv2.line(vis, (10, 10), (300, 300), color=(0, 255, 0), thickness=4) misc.imshow(vis) # draw second line, somehow previous image wasn't lost time cv2.line(vis, (50, 100), (250, 200), color=(0, 255, 0), thickness=4) misc.imshow(vis)
results imshow
:
the expected result original image 2 lines draw on top of it.
the problem occurred because image represented float32 image pixel values in range [0,1], whereas color set (0,255,0), forcing image integer representation rounded [0,1] values integers.
changing color value (0,1.0,0) fixes problem.
Comments
Post a Comment