-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from flux3dp/dev
Release 0.8b15
- Loading branch information
Showing
18 changed files
with
566 additions
and
175 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ def check_pcl(): | |
return False | ||
|
||
|
||
__version__ = "0.8b14" | ||
__version__ = "0.8b15" | ||
SUPPORT_PCL = check_pcl() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
from datetime import datetime | ||
import argparse | ||
import sys | ||
|
||
from fluxclient.commands.misc import (get_or_create_default_key, | ||
get_camera_endpoint) | ||
from fluxclient.robot import connect_camera | ||
|
||
|
||
def connect(options): | ||
endpoint, device = get_camera_endpoint(options.target, options.clientkey) | ||
|
||
def conn_callback(*args): | ||
sys.stdout.write(".") | ||
sys.stdout.flush() | ||
return True | ||
|
||
camera = connect_camera(endpoint=endpoint, server_key=device.slave_key, | ||
client_key=options.clientkey, | ||
conn_callback=conn_callback) | ||
|
||
return device, camera | ||
|
||
|
||
def serve_forever(options, device, camera): | ||
dataset = {"name": device.name, "uuid": device.uuid.hex, | ||
"ip": device.endpoint[0], "model": device.model_id, | ||
"serial": device.serial} | ||
|
||
def callback(c, imagebuf): | ||
ts = datetime.now().strftime(options.strftime) | ||
dataset["time"] = ts | ||
filename = options.filename % dataset | ||
with open(filename, "wb") as f: | ||
f.write(imagebuf) | ||
print(">> %s" % filename) | ||
|
||
camera.capture(callback) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='flux camera live') | ||
|
||
parser.add_argument(dest='target', type=str, | ||
help="Printer connect with. It can be printer uuid " | ||
"or IP address like 192.168.1.1 or " | ||
"192.168.1.1:23811") | ||
parser.add_argument('--filename', dest='filename', type=str, | ||
default="%(uuid)s-%(time)s.jpg", | ||
help='Save photo as filename') | ||
parser.add_argument('--strftime', dest='strftime', type=str, | ||
default="%Y-%m-%d-%H-%M-%S-%f", | ||
help='Formate datetime for filename') | ||
parser.add_argument('--key', dest='clientkey', type=str, default=None, | ||
help='Client identify key (A RSA pem)') | ||
options = parser.parse_args() | ||
options.clientkey = get_or_create_default_key(options.clientkey) | ||
|
||
device, camera = connect(options) | ||
|
||
try: | ||
serve_forever(options, device, camera) | ||
finally: | ||
camera.close() | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
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
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
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
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
Oops, something went wrong.