-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dca03fe
commit 83f76e0
Showing
12 changed files
with
91 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from image_utils import correct, segment | ||
import cv2 | ||
import pathlib | ||
|
||
if __name__ == '__main__': | ||
all = False | ||
save_dir = "./dataset/all/" | ||
data_root = pathlib.Path('./photos') | ||
all_image_names = sorted( | ||
item.name for item in data_root.glob('*.JPG')) # 获取文件名 | ||
if not all: | ||
image = all_image_names[0] | ||
print("image name: " + image) | ||
img_src = cv2.imread("photos/" + image) | ||
image_corrected = correct(img_src, debug=False) | ||
seg = segment(image_corrected, seg_method=4, debug=False) | ||
for seg_ele in seg: | ||
savename = image[0:-4]+"_"+str(seg_ele[2][0])+"row"+str(seg_ele[2][1])+"col.jpg" | ||
cv2.imwrite(save_dir+savename, seg_ele[1]) | ||
elif all: | ||
for image in all_image_names: | ||
print("image name: " + image) | ||
img_src = cv2.imread("photos/" + image) | ||
image_corrected = correct(img_src, debug=False) | ||
seg = segment(image_corrected, seg_method=4, debug=False) | ||
for seg_ele in seg: | ||
savename = image[0:-4] + "_" + str(seg_ele[2][0]) + "row" + str(seg_ele[2][1]) + "col.jpg" | ||
cv2.imwrite(save_dir + savename, seg_ele[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.