我有這個圖像,需要座標頭的起點和終點(直到頸部)。Opencv找到一個roi圖像的座標
我用下面的代碼來裁剪圖像,但得到下面的錯誤: -
import cv2
img = cv2.imread("/Users/pr/images/dog.jpg")
print img.shape
crop_img = img[400:500, 500:400] # Crop from x, y, w, h -> 100, 200, 300, 400
# NOTE: its img[y: y + h, x: x + w] and *not* img[x: x + w, y: y + h]
cv2.imshow("cropped", crop_img)
cv2.waitKey(0)
錯誤: -
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp, line 325
問題: -
- 如何找到座標感興趣區域的項目?
不應'x + w'大於'x'? – zindarod