-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathMotorized_Focus_Camera_Preview.py
More file actions
44 lines (41 loc) · 1.14 KB
/
Motorized_Focus_Camera_Preview.py
File metadata and controls
44 lines (41 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import time
import sys
import thread
from ctypes import *
keyboard = CDLL('./lib/libarducam_keyboard.so')
arducam_vcm =CDLL('./lib/libarducam_vcm.so')
UP = 1
DOWN = 2
SAVE = 115
focus_val = 512;
step = 10
def run_camera(name):
os.system("raspistill -t 0")
if __name__ == "__main__":
thread.start_new_thread(run_camera, ("run_camera",))
#vcm init
arducam_vcm.vcm_init()
# camera = picamera.PiCamera()
# camera.preview_fullscreen=False
# preview=camera.start_preview()
#set windows size
# preview.window=(0,0,800,600)
print("Please press up and down to adjust focus.")
while True:
keyVal = keyboard.processKeyEvent()
time.sleep(0.01)
if keyVal == UP:
print("UP")
focus_val = focus_val+step
if focus_val > 1023:
focus_val = 1023
print(focus_val)
arducam_vcm.vcm_write(focus_val)
if keyVal == DOWN:
print("DOWN")
focus_val = focus_val-step
if focus_val < 0:
focus_val = 0
print(focus_val)
arducam_vcm.vcm_write(focus_val)