object_detector_app
object_detector_app copied to clipboard
cv2.error: D:\Build\OpenCV\opencv-3.3.1\modules\imgproc\src\color.cpp:11016: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
When I use your code,I find there is a error First,I modified ['-src', '--source', dest='video_source', type=int,……] to ['-src', '--source', dest='video_source', type=str,……] Then I use this command "python object_detection_multithreading.py -src E:C.mp4",but the mistake appeared. E:\test_opencv\object_detector_app-master_PB>python object_detection_multithreading.py -src E:C.mp4 warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:808) warning: E:C.mp4 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:809) [INFO] elapsed time: 0.00 [INFO] elapsed time: 0.00 [INFO] elapsed time: 0.00 [INFO] elapsed time: 0.00 [INFO] elapsed time: 0.00
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file D:\Build\OpenCV\opencv-3.3.1\modules\imgproc\src\color.cpp, line 11016 Exception in thread Thread-1: Traceback (most recent call last): File "E:\Anaconda3\lib\threading.py", line 914, in _bootstrap_inner self.run() File "E:\Anaconda3\lib\threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "object_detection_multithreading.py", line 77, in worker frame_rgb = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) cv2.error: D:\Build\OpenCV\opencv-3.3.1\modules\imgproc\src\color.cpp:11016: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
How to fix it?
May you modify your path of the file.
Maybe your computer can not connect to camera by python. You should check your python code if it could access your camera first. Best, Thu
I alse have the problem:anyone can help me?
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/pi/opencv-3.3.0/modules/imgproc/src/color.cpp, line 10638
Traceback (most recent call last):
File "faceDetection.py", line 21, in
import cv2 import sys
cascPath = "/haarcascades/haarcascade_frontalface_default.xml" faceCascade = cv2.CascadeClassifier(cascPath)
video_capture = cv2.VideoCapture(0)
while True: # Capture frame-by-frame ret, frame = video_capture.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30, 30),
flags=cv2.cv.CV_HAAR_SCALE_IMAGE
)
# Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
# Display the resulting frame
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
When everything is done, release the capture
video_capture.release() cv2.destroyAllWindows()
after running above code getting below error : Request to any one to help in this
File "C:/Users/Ahil Rayyan/Desktop/Face Recog Project/07_Nov_2018_V0.1/Video testing.py", line 13, in
error: OpenCV(3.4.1) C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\modules\imgproc\src\color.cpp:11147: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
i also encountered the error when i tred to show my images in my computer ,the code is as follows:
import cv2 import matplotlib.pyplot as plt extractdir = r'F:/Python exercise/Machine Learning for OpenC/pedestrians128x64' for i in range(5): filename = '%s/per0001%d.pmm' % (extractdir, i) img = cv2.imread(filename) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) plt.subplot(1, 5, i+1 ) plt.imshow(img) # img_rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB) plt.axis('off')
the result : cv2.error: C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:10606: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
what can i do to fix it
MR QJXX, I also face the same problem. tell me solution if that is you know
MR QJXX, I also face the same problem. tell me solution if that is you know, please
OpenCV(3.4.1) Error: Assertion failed ((scn == 3 || scn == 4) && (depth == 0 || depth == 5)) in cv::cvtColor, file C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\modules\imgproc\src\color.cpp, line 11214 Traceback (most recent call last)