Created
March 7, 2021 11:27
-
-
Save ma2shita/a6ad200bea550f7211636783f17539b9 to your computer and use it in GitHub Desktop.
Focus control for Arducam B0176 "Motorized focus camera for Raspberry Pi"
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
#!/bin/env python3 | |
""" | |
Focus control for Arducam B0176 "Motorized focus camera for Raspberry Pi" | |
See: TBC | |
Copyright (c) 2021 Kohei MATSUSHITA | |
This software is released under the The 3-Clause BSD License. | |
https://opensource.org/licenses/BSD-3-Clause | |
""" | |
import sys | |
import argparse | |
class range_check(): | |
def __init__(self): | |
self.min = 0 | |
self.max = 1023 | |
def __contains__(self, val): | |
return (self.min <= val and val <= self.max) | |
def __iter__(self): | |
return iter(("Integer", "{} <= N <= {}".format(self.min, self.max))) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--focus", type=int, dest="focus", required=True, choices=range_check(), help="Camera focus 0(far)..1023(near)") | |
args = parser.parse_args() | |
print("Focus set to {}".format(args.focus), file=sys.stderr) | |
from ctypes import CDLL | |
arducam_vcm = CDLL('libarducam_vcm.so') | |
arducam_vcm.vcm_init() | |
arducam_vcm.vcm_write(args.focus) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment