当我使用python virtualenv和OpenCV在Linux系统中运行此代码时:
import glob as gb
import cv2
import random
import os
img_path_htc=gb.glob("/home/project/venv/data/train/new/*.jpg")
counter= 1
for path in img_path_htc:
img = cv2.imread(path)
cv2.imshow("img",img)
cv2.waitKey(1000)
for i in range(10):
x = random.randint(300, img.shape[1] - 300 - 256 )
y = random.randint(300, img.shape[0] - 300 - 256 )
crop_img = img[y:y+256,x:x+256]
save_path = "/home/project/venv/data/train/new/patch"
filename='img'+str(counter)+'.jpg'
counter=counter+1
savepath = os.path.join(save_path,filename)
cv2.imshow("crop_img"+str(i),crop_img)
cv2.imwrite(savepath, crop_img)
cv2.waitKey(1000)
我收到了这个错误:
QObject::moveToThread: Current thread (0x128e5e0) is not the object's thread (0x193bf70).
Cannot move to target thread (0x128e5e0)
感谢。