opencv를 처음 사용하며 그것에 대해 자세히 알고 싶습니다. 여기 내 파이프 라인이다 :Opencv 및 그립 비전 머신 기반 [TypeError : src가 숫자가 아닌 배열이거나 스칼라가 아닙니다.]
import cv2
import numpy
import math
from enum import Enum
class GripPipeline:
"""
An OpenCV pipeline generated by GRIP.
"""
def __init__(self):
"""initializes all values to presets or None if need to be set
"""
self.__cv_resize_dsize = (0, 0)
self.__cv_resize_fx = 0.25
self.__cv_resize_fy = 0.25
self.__cv_resize_interpolation = cv2.INTER_LINEAR
self.cv_resize_output = None
self.__hsv_threshold_input = self.cv_resize_output
self.__hsv_threshold_hue = [0.4556876738819602, 93.45444422147858]
self.__hsv_threshold_saturation = [37.56692583788217, 145.8721694981769]
self.__hsv_threshold_value = [1.7210414835158088, 187.92607745473873]
self.hsv_threshold_output = None
self.__cv_erode_src = self.hsv_threshold_output
self.__cv_erode_kernel = None
self.__cv_erode_anchor = (-1, -1)
self.__cv_erode_iterations = 1.0
self.__cv_erode_bordertype = cv2.BORDER_CONSTANT
self.__cv_erode_bordervalue = (-1)
self.cv_erode_output = None
self.__mask_input = self.cv_resize_output
self.__mask_mask = self.cv_erode_output
self.mask_output = None
self.__find_blobs_input = self.mask_output
self.__find_blobs_min_area = 16.0
self.__find_blobs_circularity = [0.0, 1.0]
self.__find_blobs_dark_blobs = False
self.find_blobs_output = None
def process(self, source0):
"""
Runs the pipeline and sets all outputs to new values.
"""
# Step CV_resize0:
self.__cv_resize_src = source0
(self.cv_resize_output) = self.__cv_resize(self.__cv_resize_src, self.__cv_resize_dsize, self.__cv_resize_fx, self.__cv_resize_fy, self.__cv_resize_interpolation)
# Step HSV_Threshold0:
/code/
# Step CV_erode0:
/code/
# Step Mask0:
/code/
# Step Find_Blobs0:
/code/
@staticmethod
def __cv_resize(src, d_size, fx, fy, interpolation):
"""Resizes an Image.
Args:
src: A numpy.ndarray.
d_size: Size to set the image.
fx: The scale factor for the x.
fy: The scale factor for the y.
interpolation: Opencv enum for the type of interpolation.
Returns:
A resized numpy.ndarray.
"""
return cv2.resize(src, d_size, fx=fx, fy=fy, interpolation=interpolation)
"DEF"거기 많이 있습니다 그리고 내 내가 그것에서 IMG을 포착하려 있기 때문에 카메라 문제가되지 않습니다 내가 확신 내 노트북 카메라 를 사용하여 객체 를 생성 나는 성공한다. :
My_Pipeline = GripPipeline()
My_Pipeline.process(cv2.VideoCapture(0))
이 제기 오류 :
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
My_Pipeline.process(cv2.VideoCapture(0))
File "C:\Users\lenovo\Desktop\grip.py", line 57, in process
(self.cv_resize_output) = self.__cv_resize(self.__cv_resize_src,
self.__cv_resize_dsize, self.__cv_resize_fx, self.__cv_resize_fy,
self.__cv_resize_interpolation)
File "C:\Users\lenovo\Desktop\grip.py", line 89, in __cv_resize
return cv2.resize(src, d_size, fx=fx, fy=fy,
interpolation=interpolation)
TypeError: src is not a numpy array, neither a scalar
내가 OpenCV의 새로운 오전 그냥 더 배우고 싶어요! 이 문제를 검토해 주셔서 감사합니다.
를 많이 참조하십시오! lol – Billvace
그리고 cv2.read는 cap.read()이어야합니다. – Billvace
@Billvace corrected My bad – ZdaR