Elif中的cv2.cvtColor错误(错误:(-2:未指定错误))

时间:2019-07-21 16:34:35

标签: python opencv

我是新手,我不了解此错误,看起来像第20行中elif的错误,但我不确定这一点

我试图将'YUV'更改为其他名称,它可以工作,但是有错误。任何人都可以帮助我

def extract_features(imgs, color_space='RGB', spatial_size=(32, 32),
                        hist_bins=32, orient=9, 
                        pix_per_cell=8, cell_per_block=2, hog_channel=0,
                        spatial_feat=True, hist_feat=True, hog_feat=True):
    # Create a list to append feature vectors to
    features = []
    # Iterate through the list of images
    for file in imgs:
        file_features = []
        # Read in each one by one
        image = mpimg.imread(file)
        # apply color conversion if other than 'RGB'
        if color_space != 'RGB':
            if color_space == 'HSV':
                feature_image = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
            elif color_space == 'LUV':
                feature_image = cv2.cvtColor(image, cv2.COLOR_RGB2LUV)
            elif color_space == 'HLS':
                feature_image = cv2.cvtColor(image, cv2.COLOR_RGB2HLS)
            elif color_space == 'YUV':enter code here
                feature_image = cv2.cvtColor(image, cv2.COLOR_RGB2YUV)
            elif color_space == 'YCrCb':
                feature_image = cv2.cvtColor(image, cv2.COLOR_RGB2YCrCb)
        else: feature_image = np.copy(image)
  

(ipython-input-9-1d2d8a265ab9)在extract_features(imgs,color_space,   空间大小,hist_bins,orient,pix_per_cell,cell_per_block,   hog_channel,spatial_feat,hist_feat,hog_feat)

>      19                 feature_image = cv2.cvtColor(image, cv2.COLOR_RGB2HLS)
>      20             elif color_space == 'YUV':
> ---> 21                 feature_image = cv2.cvtColor(image, cv2.COLOR_RGB2YUV)
>      22             elif color_space == 'YCrCb':
>      23                 feature_image = cv2.cvtColor(image, cv2.COLOR_RGB2YCrCb)
  

错误:OpenCV(4.1.0)   d:\ build \ opencv \ opencv-4.1.0 \ modules \ imgproc \ src \ color.simd_helpers.hpp:92:   错误:函数'__cdecl中的(-2:未指定错误)   cv :: impl :: anonymous-namespace'::CvtHelper<struct cv::impl::匿名   名称空间':: Set <3,4,-1>,struct   cv :: impl :: A0xfa7cfaf3 :: Set <3,-1,-1>,结构   cv :: impl :: A0xfa7cfaf3 :: Set <0,2,5>,2> :: CvtHelper(const class   cv :: _ InputArray&,const class cv :: _ OutputArray&,int)'

     
    

输入图像中无效的通道数:         'VScn :: contains(scn)'     哪里         “ scn”是1

  

0 个答案:

没有答案