import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
img = cv.imread('t2.jpg', cv.COLOR_BGR2GRAY)
blur = cv.GaussianBlur(img, (5, 5), 0)
ret3, th3 = cv.threshold(blur, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)
I get the error:
Traceback (most recent call last):
File "F:/l4 project docs/project/l4proTest1/projectionStepTest.py", line 11, in <module>
ret3,th3 = cv.threshold(blur, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)
cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-9d_dfo3_\opencv\modules\imgproc\src\thresh.cpp:1557: error: (-2:Unspecified error) in function 'double __cdecl cv::threshold(const class cv::_InputArray &,const class cv::_OutputArray &,double,double,int)'
THRESH_OTSU mode:
'src_type == CV_8UC1 || src_type == CV_16UC1'
where
'src_type' is 16 (CV_8UC3)
Process finished with exit code 1
img = cv.imread('t2.jpg', cv.IMREAD_GRAYSCALE)
or
img = cv.imread('t2.jpg', cv.IMREAD_COLOR)
img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With