a = np.array([[[255,0,0]]*100]*100)
a = cv2.cvtColor(a, cv2.COLOR_RGB2BGR)
plt.imshow(a)
I got this error.
error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:94: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<3, 4>; VDepth = cv::impl::{anonymous}::Set<0, 2, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = (cv::impl::<unnamed>::SizePolicy)2u; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
a = np.array([[[255,0,0]]*100]*100,np.uint8)
a = cv2.cvtColor(a, cv2.COLOR_RGB2BGR)
plt.imshow(a)
By default, np.array defaults to int64. However, the argument of cv2.cvtColor () must be uint8, uint16.
https://stackoverflow.com/questions/50319617/opencv-error-cv2-cvtcolor https://postd.cc/image-processing-101/
Recommended Posts