added basic cropping
This commit is contained in:
parent
4ea4d6f142
commit
ff5f0ba151
@ -40,7 +40,7 @@ for file in os.listdir(input_folder):
|
|||||||
filename = input_folder + '/' + file
|
filename = input_folder + '/' + file
|
||||||
out_filename = output_folder + '/' + file
|
out_filename = output_folder + '/' + file
|
||||||
img = cv2.imread(filename, 0)
|
img = cv2.imread(filename, 0)
|
||||||
small_img = cv2.resize(img, (400, 400))
|
small_img = cv2.resize(img, (750, 750))
|
||||||
(corners, ids, rejected) = detector.detectMarkers(small_img)
|
(corners, ids, rejected) = detector.detectMarkers(small_img)
|
||||||
new_image = cv2.aruco.drawDetectedMarkers(
|
new_image = cv2.aruco.drawDetectedMarkers(
|
||||||
small_img,
|
small_img,
|
||||||
@ -73,12 +73,18 @@ for file in os.listdir(input_folder):
|
|||||||
print("x[%d]: %d"%(i, x[i]))
|
print("x[%d]: %d"%(i, x[i]))
|
||||||
print("y[%d]: %d"%(i, y[i]))
|
print("y[%d]: %d"%(i, y[i]))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
offset = 20
|
||||||
|
crop_img = new_image[
|
||||||
|
np.min(x+offset):np.max(x-offset),
|
||||||
|
np.min(y+offset):np.max(y-offset)
|
||||||
|
]
|
||||||
|
|
||||||
print("imshape[0]: " + str(small_img.shape[0]))
|
print("imshape[0]: " + str(small_img.shape[0]))
|
||||||
print("imshape[1]: " + str(small_img.shape[1]))
|
print("imshape[1]: " + str(small_img.shape[1]))
|
||||||
cv2.imshow('window', new_image)
|
cv2.imshow('window', new_image)
|
||||||
|
cv2.imshow('cropped', crop_img)
|
||||||
# cv2.imwrite(out_filename, new_image)
|
# cv2.imwrite(out_filename, new_image)
|
||||||
|
|
||||||
cv2.waitKey(0)
|
cv2.waitKey(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user