Skip to content
Snippets Groups Projects
Commit db23e0fc authored by zalonzo2's avatar zalonzo2
Browse files

Added argument show_cam

parent 8737240e
No related branches found
No related tags found
No related merge requests found
...@@ -14,10 +14,11 @@ import time ...@@ -14,10 +14,11 @@ import time
from picamera2 import Picamera2, Preview from picamera2 import Picamera2, Preview
class ChessGame: class ChessGame:
def __init__(self, difficulty, show_cv, test_img = None): def __init__(self, difficulty, show_cv, show_cam, test_img = None):
self.board = chess.Board() self.board = chess.Board()
self.difficulty = difficulty self.difficulty = difficulty
self.show_cv = show_cv self.show_cv = show_cv
self.show_cam = show_cam
self.test_img = test_img self.test_img = test_img
self.img_idx = 0 self.img_idx = 0
self.picam2 = Picamera2() self.picam2 = Picamera2()
...@@ -30,8 +31,15 @@ class ChessGame: ...@@ -30,8 +31,15 @@ class ChessGame:
init_show_cv(self.show_cv) init_show_cv(self.show_cv)
preview_config = self.picam2.create_preview_configuration(main={"size": (512, 512)}) preview_config = self.picam2.create_preview_configuration(main={"size": (512, 512)})
self.picam2.configure(preview_config) self.picam2.configure(preview_config)
if (self.show_cam):
self.picam2.start_preview(Preview.QTGL)
self.picam2.start()
input("Press enter to continue.")
else:
self.picam2.start()
# self.get_img() # self.get_img()
...@@ -86,8 +94,6 @@ class ChessGame: ...@@ -86,8 +94,6 @@ class ChessGame:
def take_pic(self): def take_pic(self):
self.img_idx += 1 self.img_idx += 1
# self.picam2.start_preview(Preview.QTGL)
self.picam2.start()
time.sleep(2) time.sleep(2)
img_txt = 'board' + str(self.img_idx) + '.jpg' img_txt = 'board' + str(self.img_idx) + '.jpg'
print(img_txt) print(img_txt)
...@@ -100,8 +106,9 @@ if __name__ == "__main__": ...@@ -100,8 +106,9 @@ if __name__ == "__main__":
parser.add_argument("--difficulty", choices=["easy", "medium", "hard"], parser.add_argument("--difficulty", choices=["easy", "medium", "hard"],
default="medium", help="Chess AI difficulty (how far it looks ahead)") default="medium", help="Chess AI difficulty (how far it looks ahead)")
parser.add_argument("--show_cv", action="store_true", help="Show opencv images as processing occurs during game") parser.add_argument("--show_cv", action="store_true", help="Show opencv images as processing occurs during game")
parser.add_argument("--show_cam", action="store_true", help="Show persistent camera view")
parser.add_argument("--test_img", help="If specified, will use said image in test_images folder rather than camera input") parser.add_argument("--test_img", help="If specified, will use said image in test_images folder rather than camera input")
args = parser.parse_args() args = parser.parse_args()
game = ChessGame(args.difficulty, args.show_cv, args.test_img) game = ChessGame(args.difficulty, args.show_cv, args.show_cam, args.test_img)
game.start_game() game.start_game()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment