0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

画像ビューワー、ボタン操作、JSONで保存 #メモ

Posted at

WSLで実行する場合は下記参照
https://dev.classmethod.jp/articles/wsl-x-window/


# -*- coding: utf-8 -*-
import cv2
import glob
import json

target = "target/*.png"
print("target:"+target)

data_BasePath = sorted(glob.glob(target))
print("target:"+target)

data_BasePath = sorted(glob.glob(target))
print("image Num:"+ str(len(data_BasePath)))

yesno_dict={}
# for idx_inter, data_BasePath_png in enumerate(data_BasePath): 
idx_inter = 0
while True:
    data_BasePath_png = data_BasePath[idx_inter]
    # 入力画像のロード
    img = cv2.imread(data_BasePath_png)
    img = cv2.resize(img, (img.shape[1]*4, img.shape[0]*4))
    cv2.imshow("input", img)

    k = cv2.waitKey(0)
    if k == 27:         # wait for ESC key to exit
        break
    elif k == ord('y'): 
        imgbool = "1"
    elif k == ord('n'): 
        imgbool = "0"
    elif k == ord('p'): 
        idx_inter = idx_inter - 2
    else:
        idx_inter = idx_inter - 1

    print([data_BasePath_png, imgbool])
    yesno_dict[data_BasePath_png] = imgbool
    idx_inter = idx_inter + 1

print(yesno_dict)

cv2.destroyAllWindows()

tf = open("myDictionary.json", "w")
json.dump(yesno_dict, tf)
tf.close()

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?