I want the output window with a green square at the center.
import cv2 as cv
import numpy as np
blank = np.zeros((500, 500, 3), dtype=np.int8)
blank[200:300, 200:300] = 0, 255, 0
cv.imshow('Blank', blank)
cv.waitKey(0)
This is showing me just a grey background but not a green square in the center but if I change
dtype=np.int8
-> dtype=np.uint8
I'm getting what I want.
So I just want to know the difference between dtype=np.int8
and dtype=np.uint8
.
The "u" in "uint" is short for "unsigned", meaning the integer doesn't have a sign (it can't be negative).
Signed 8 bit integers values go from -128 to +127, while unsigned go from 0 to 255 : The classic "byte"