本文整理汇总了Python中box.Box.upload_photo方法的典型用法代码示例。如果您正苦于以下问题:Python Box.upload_photo方法的具体用法?Python Box.upload_photo怎么用?Python Box.upload_photo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类box.Box
的用法示例。
在下文中一共展示了Box.upload_photo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Camera
# 需要导入模块: from box import Box [as 别名]
# 或者: from box.Box import upload_photo [as 别名]
class Camera(object):
OBJECT_EVENT_ALL = 0x200
PROP_SAVE_TO = 0xb
PROP_VAL_SAVE_TO_PC = 2
DIR_ITEM_CONTEXT_CHANGED = 0x00000208
PROP_EVENT_ALL = 0x100
PROP_EVENT_PROP_CHANGED = 0x101
PROP_EVF_MODE = 0x501
def __init__(self):
self._create_sdk()
self._filename = None
self._camera = None
self._box = Box()
self._photo_queue = Queue()
self._photo_thread = Thread(target=self._process_queue)
self._photo_thread.daemon = True
self._photo_thread.start()
self._name = None
self._message = None
self._photos = []
self._waiting_for_callback = False
self._event_object = None
self._no_shutdown_thread = None
self._stop_no_shutdown_thread = False
def _create_sdk(self):
if sys.platform == 'darwin':
library_path = ('edsdk', 'EDSDK', 'Frameworks', 'EDSDK.Framework', 'Versions', 'A', 'EDSDK')
else:
library_path = ('Windows', 'EDSDK', 'Dll', 'EDSDK.dll')
self._sdk = dll.LoadLibrary(os.path.join(os.getcwd(), *library_path))
def _process_queue(self):
while True:
try:
self._box.upload_photo(*self._photo_queue.get())
except:
pass
@contextmanager
def _initialized_sdk(self):
initialize_error = self._sdk.EdsInitializeSDK()
print 'initialize', initialize_error
if initialize_error:
raise RuntimeError('Could not inititalize SDK.')
try:
yield
finally:
print 'terminate', self._sdk.EdsTerminateSDK()
@contextmanager
def _camera_session(self):
camera_list_ref = c_int()
camera_list_error = self._sdk.EdsGetCameraList(byref(camera_list_ref))
print 'get list', camera_list_error
self._camera = c_int()
camera_error = self._sdk.EdsGetChildAtIndex(camera_list_ref, 0, byref(self._camera))
print 'get camera', camera_error
print self._camera
session_error = self._sdk.EdsOpenSession(self._camera)
print 'open session', session_error
self._shutdown_thread = ComThread(target=self._extend_shutdown)
self._shutdown_thread.daemon = True
self._shutdown_thread.start()
ui_lock_error = self._sdk.EdsSendStatusCommand(self._camera, 0, 0)
print 'lock ui', ui_lock_error
try:
yield self._camera
finally:
ui_unlock_error = self._sdk.EdsSendStatusCommand(self._camera, 1, 0)
print 'unlock ui', ui_unlock_error
close_session_error = self._sdk.EdsCloseSession(self._camera)
print 'close session', close_session_error
self._camera = None
self._no_shutdown_thread = True
self._shutdown_thread = None
def _extend_shutdown(self):
while not self._no_shutdown_thread:
sleep(60)
try:
self._sdk.EdsSendCommand(self._camera, 0x01, 0)
except:
pass
self._no_shutdown_thread = False
@contextmanager
def live_view(self):
#EdsCreateEvfImageRef, EdsDownloadEvfImage, kEdsCameraCommand_DoEvfAf
size = sizeof(c_int)
evf_on_error = self._sdk.EdsSetPropertyData(self._camera, 0x00000501, 0, size, pointer(c_int(1)))
print 'evf on', evf_on_error # Turn on EVF
evf_pc_error = self._sdk.EdsSetPropertyData(self._camera, 0x00000500, 0, size, pointer(c_int(2)))
print 'evf pc', evf_pc_error # Set EVF device to PC
af_live_face_error = self._sdk.EdsSetPropertyData(self._camera, 0x0000050E, 0, size, pointer(c_int(2)))
print 'evf af live face', af_live_face_error # Set AF Mode to live face
stream = c_int()
sys_path = os.path.abspath(os.path.join('evf', 'evf.jpg'))
sys_path_p = c_char_p()
#.........这里部分代码省略.........