Using `imread` to read a image then multiply a number in one line, the value is wrong! BUG?

I use cv2.imread to read a depth map like depth = 200*cv2.imread(path,-1)/65535. But I found the value is invalid! When I change my code to depth = 200.0*cv2.imread(path,-1)/65535, it looks right. Besides, when I read the depth like depth = cv2.imread(path,-1)/65535 depth *= 200, it looks right too!

Is that a bug of opencv or numpy?

The bug is in your code - with the multiplication by 200 your 16 bit values will overflow

1 Like

and that magic number should be written as cv.IMREAD_UNCHANGED

1 Like

OMG!Thank you! Iā€™m too careless!

Thanks for your reply!
I searched the document of opencv, -1 equals with cv::IMREAD_UNCHANGED. You can find it here.