Some OpenCV functions have restrictions on the input data type. When executing the cv2. Function () in python, an error may occur due to a mistake in specifying the ddepth of the input data type and output data depth. In the error message, values such as cv2.CV_8U are displayed as integers, so I'm confused as to what the input data type should be and how to specify the ddepth of the output data depth. I have something to do.
Similarly, building from the source code of the cv :: function () in C ++ may fail.
I will make a note so as not to repeat the same mistake.
dilate(...) dilate(src, kernel[, dst[, anchor[, iterations[, borderType[, borderValue]]]]]) -> dst
function | CV_8U | CV_8S | CV_16U | CV_16S | CV_32S | CV_32F | CV_64F |
---|---|---|---|---|---|---|---|
value | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
np.dtype | uint8 | int8 | uint16 | int16 | int32 | float32 | float64 |
cv2.dilate() | o | x | o | o | x | o | o |
cv2.erode() | o | x | o | o | x | o | o |
connectedComponentsWithStats() input | o | x | x | x | x | x | x |
connectedComponentsWithStats() labels | x | x | o | x | o | x | x |
connectedComponentsWithStats() stats | x | x | x | x | o | x | x |
connectedComponentsWithStats() centroids | x | x | x | x | x | x | o |
function | CV_8U | CV_8S | CV_16U | CV_16S | CV_32S | CV_32F | CV_64F |
---|---|---|---|---|---|---|---|
np.dtype | uint8 | int8 | uint16 | int16 | int32 | float32 | float64 |
cv2.Sobel() src | o | x | o | o | x | o | o |
cv2.Sobel() dst | o | x | o | o | x | o | o |
cv2.blur() src | o | x | o | o | o | o | o |
GaussianBlur() src | o | x | o | o | x | o | o |
filter2D() src | o | x | o | o | x | o | o |
cartToPolar() src | x | x | x | x | x | o | o |
polarToCart() src | x | x | x | x | x | o | o |
magnitude() src | x | x | x | x | x | o | o |
phase() src | x | x | x | x | x | o | o |
cv2.sqrt() src | x | x | x | x | x | o | o |
cvtColor() | o | x | o | x | x | o | x |
I haven't fully checked the combination yet.
Sobel(...) Sobel(src, ddepth, dx, dy[, dst[, ksize[, scale[, delta[, borderType]]]]]) -> dst
Sobel combination Input image src type: vertical axis Determines the type of output image ddepth: Horizontal axis
CV_8U | CV_8S | CV_16U | CV_16S | CV_32S | CV_32F | CV_64F | |
---|---|---|---|---|---|---|---|
np.uint8 | o | x | o | o | x | o | o |
np.int8 | x | x | x | x | x | x | x |
np.uint16 | o | x | o | o | x | o | o |
np.int16 | o | x | o | o | x | o | o |
np.int32 | x | x | x | x | x | x | x |
np.float32 | o | x | o | o | x | o | o |
np.float64 | o | x | o | o | x | x | o |
Combination of cv2.filter2D (np.array (orgImg, dtype = npt), ddepth, kernel) Input image src type: vertical axis Determines the type of output image ddepth: Horizontal axis
CV_8U | CV_8S | CV_16U | CV_16S | CV_32S | CV_32F | CV_64F | |
---|---|---|---|---|---|---|---|
np.uint8 | o | x | o | o | x | o | o |
np.int8 | x | x | x | x | x | x | x |
np.uint16 | x | x | o | x | x | o | o |
np.int16 | x | x | x | o | x | o | o |
np.int32 | x | x | x | x | x | x | x |
np.float32 | x | x | x | x | x | o | x |
np.float64 | x | x | x | x | x | x | o |
function | CV_8U | CV_8S | CV_16U | CV_16S | CV_32S | CV_32F | CV_64F |
---|---|---|---|---|---|---|---|
np.dtype | uint8 | int8 | uint16 | int16 | int32 | float32 | float64 |
cv2.threshold() src | o | o | x | x | x | o | x |
cv2.floodFill() src | o | o | x | x | x | o | x |
function | CV_8U | CV_8S | CV_16U | CV_16S | CV_32S | CV_32F | CV_64F |
---|---|---|---|---|---|---|---|
np.dtype | uint8 | int8 | uint16 | int16 | int32 | float32 | float64 |
cv2.Canny() src | o | o | x | x | x | x | x |
cv2.HoughLines()src Binary image | o | ? | x | x | x | x | x |
cv2.HoughCircles()src Binary image | o | ? | x | x | x | x | x |
# -*- coding: utf-8 -*-
u"""OpenCV cv::Check Mat type in Python
"""
import cv2
print cv2.CV_8U
print cv2.CV_8S
print cv2.CV_16U
print cv2.CV_16S
print cv2.CV_32S
print cv2.CV_32F
print cv2.CV_64F
Recommended Posts