CV ::ColorMap only supports source images of type CV_8UC1 or CV_8UC3 in function cv2.applycolormap () error
recently used cv2.cv2.applycolormap () to convert a 2-d ndarray into a pseudo-color image. It is found that an error message “CV ::ColorMap only supports source images of type CV_8UC1 or CV_8UC3 in function” is frequently popped. It is found that the 2-d nDARray element data type must be converted to NP. uint8 type.
import numpy as np
import cv2
a = np.ones((2,3))
b = a.astype(np.uint8)
img1 = cv2.applyColorMap(a, cv2.COLORMAP_JET) # 报错
img2 = cv2.applyColorMap(b, cv2.COLORMAP_JET) # 正常
div>
Read More:
- AttributeError: module ‘cv2.cv2‘ has no attribute ‘face‘
- Undeclared identifier CV in opencv4.2.0_ WINDOW_ AUTOSIZE
- error: ‘CV_BGR2GRAY’ was not declared in this scope
- OpenCV error: (-215:Assertion failed) !_src.empty() in function ‘cv::cvtColor‘
- (-2:Unspecified error) could not find a writer for the specified extension in function‘cv::imwrite_
- When VS code imported Cv2, an error ImportError: numpy.core.multiarray failed to import; There are no mistakes in using the Spyder
- How to solve “import cv2 failed ImportError: DLL load fail: Cannot find the specified module” in Anaconda environment
- Successfully solved opencv error: assertion failed (SCN = = 3 | SCN = = 4) in CV:: cvtcolor
- cv2.error: OpenCV(3.4.2) error: (-215:Assertion failed) !empty() in function ‘detectMultiScale‘
- (-215:Assertion failed) 0 <= contourIdx && contourIdx < (int)last in function ‘cv::drawContours‘
- Using CV2 to solve sliding verification code
- Opencv, CV2. Puttext() usage
- cv2 error – function not implemented [How to Solve]
- [Solved] caffe Error: Check failed: cv_img.data Could not load
- Installing open CV under Linux system
- Importerror: the perfect solution of no module named CV2!!! (not too good)
- Opencv does not define identifier cv_ CAP_ PROP_ FRAME_ COUNT