You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
10 years ago
|
import subprocess
|
||
|
import tempfile
|
||
|
|
||
|
from bureau import Bureau, add_api
|
||
|
|
||
|
|
||
|
class Photography(Bureau):
|
||
|
"""
|
||
|
The Photography dept. provides document camera and other image
|
||
9 years ago
|
capture services for other bureaus.
|
||
10 years ago
|
"""
|
||
|
|
||
|
name = "Photography Dept."
|
||
|
prefix = "PX"
|
||
|
version = 0
|
||
|
|
||
|
def __init__(self):
|
||
|
Bureau.__init__(self)
|
||
|
|
||
|
@add_api("photo", "Get Document Photo")
|
||
9 years ago
|
def photo(self):
|
||
10 years ago
|
"""
|
||
|
Takes a photograph using the document camera. Returns
|
||
|
the file name.
|
||
|
"""
|
||
|
tmpimg = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False)
|
||
|
tmpimg.close()
|
||
9 years ago
|
|
||
|
# this is a dirty hack to keep the webcam system calls from hanging
|
||
|
cmd1 = "fswebcam --jpeg 95 --no-banner --resolution 320x240 /dev/null"
|
||
|
cmd2 = "fswebcam --jpeg 95 --no-banner --resolution 1920x1080 "
|
||
|
cmd2 += "-F 2 -S 1" + tmpimg.name
|
||
|
subprocess.check_output(cmd1.split())
|
||
|
subprocess.check_output(cmd2.split())
|
||
|
return {"photo": tmpimg.name}
|
||
10 years ago
|
|
||
|
|
||
9 years ago
|
def main():
|
||
10 years ago
|
px = Photography()
|
||
|
px.run()
|
||
9 years ago
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|