TypeError:参数'src'的预期Ptr <cv :: UMat>-Sliding_Window

问题描述

在Jupyter Notebook的滑动窗口中训练模型时出现以下错误

TypeError                                 Traceback (most recent call last)
<ipython-input-33-258a109a8532> in <module>
     18     index = i + startIndex
     19     img = cv2.imread('C:/Users/hp/Desktop/Mod1-IITR/test/' + str(index) + '.jpg')
---> 20     img_with_label = label_vehicles(img,X_scaler)
     21     axarr[i].imshow(img_with_label)
     22 plt.setp([a.get_xticklabels() for a in axarr[:]],visible=False)

<ipython-input-33-258a109a8532> in label_vehicles(image,X_scaler)
      1 def label_vehicles(image,X_scaler):
      2     draw_image = np.copy(image)
----> 3     draw_image = cv2.cvtColor(draw_image,cv2.COLOR_RGB2BGR)
      4     windows = slide_window(image,x_start_stop=[None,None],y_start_stop=y_start_stop)
      5     hot_windows = search_windows(image,windows,svc,X_scaler,color_space=color_space,TypeError: Expected Ptr<cv::UMat> for argument 'src'

我的代码是这个

def label_vehicles(image,X_scaler):
    draw_image = np.copy(image)
    draw_image = cv2.cvtColor(draw_image,cv2.COLOR_RGB2BGR)
    windows = slide_window(image,y_start_stop=y_start_stop)
    hot_windows = search_windows(image,spatial_size=spatial_size,hist_bins=hist_bins,orient=orient,pix_per_cell=pix_per_cell,cell_per_block=cell_per_block,hog_channel=hog_channel,spatial_feat=spatial_feat,hist_feat=hist_feat,hog_feat=hog_feat)                       

    window_img = draw_Boxes(draw_image,hot_windows,color=(0,255),thick=6)  
    return window_img

f,axarr = plt.subplots(1,1,figsize=(16,12))
startIndex = random.randint(1,40)
for i in range(7,8):
    index = i + startIndex
    img = cv2.imread('C:/Users/hp/Desktop/Mod1-IITR/test/' + str(index) + '.jpg')
    img_with_label = label_vehicles(img,X_scaler)
    axarr[i].imshow(img_with_label)
plt.setp([a.get_xticklabels() for a in axarr[:]],visible=False)
plt.setp([a.get_yticklabels() for a in axarr[:]],visible=False)
f.subplots_adjust(hspace=0)
plt.show()

我已经写了范围(7,8),因为我只想在1张图像上看到结果。我该怎么办才能解决错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...