Attribute of Video and reference pixel value

less than 1 minute read

Attribute of Video and reference pixel value



1. Open CV express the video data to use numpy.ndarray

import cv2
img1 = cv2.imread(‘cat.bmp’,cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread(‘cat.bmp’,cv2.IMREAD_COLOR)
  • ndim : the number of dimension. = len(img.shape)
  • shape : the size of each dimension. * Grayscale = (h,w), Colorscale = (h,w,3)
  • size : Total number of elements
  • dytp : Data type of elements. ex) Video data is uint8



2. OpenCV data type and Numpy data type

cv.CV_8U numpy.unint8 8-bit unsigned integer
cv.CV_16S numpy.int16 16-bit signed integer
cv.CV_32F numpy.float32 32-bit floating point
  • Grayscale Video : cv2.CV_8UC1 -> numpy.uint8, shape = (h,w)
  • Colorscale Video : cv2.CV_8UC1 -> numpy.uint8, shape = (h,w,3)



3. Mask Operation and ROI

  • ROI
    • Region of Interest
    • Specific region that could special operation in the video.
  • Mask Operation
    • OpenCV support ROI operaion to some of function when it do the mask Video should be converted.
    • Generally, Mask video is used through the binary image ,which is composed of 0 or 255.
  • Pixel value copy function supporting mask operation.
cv2.copyTo(src,maks,dst=None) -> dst
  • src : input video
  • mask : mask video
  • sdt : output layer

Leave a comment