Esempio n. 1
0
import edsdk

def pic_taken(filename):
    print("got picture: " + filename)
    global cam
    cam.disconnect()
    edsdk.terminate()

def got_camera(c):
    global cam
    cam = c
    if cam is None:
        print("no cam connected")
        edsdk.terminate()
    else:
        print("taking picture")
        cam.setPictureCompleteCallback(pic_taken)
        cam.takePicture("C:\\test.jpg")

def got_name(name):
    print("Camera name: " + name)

def err(level, msg):
    print(msg)

edsdk.setErrorLevel(edsdk.ErrorLevel.Warn)
edsdk.setErrorMessageCallback(err)

edsdk.getFirstCamera(got_camera)
Esempio n. 2
0
    print("got picture: " + filename)
    global cam
    cam.disconnect()
    edsdk.terminate()


def got_camera(c):
    global cam
    cam = c
    if cam is None:
        print("no cam connected")
        edsdk.terminate()
    else:
        print("taking picture")
        cam.setPictureCompleteCallback(pic_taken)
        cam.takePicture("C:\\test.jpg")


def got_name(name):
    print("Camera name: " + name)


def err(level, msg):
    print(msg)


edsdk.setErrorLevel(edsdk.ErrorLevel.Warn)
edsdk.setErrorMessageCallback(err)

edsdk.getFirstCamera(got_camera)
Esempio n. 3
0
from functools import wraps

# dependencies
import edsdk
import silverpak


def camera_error_handler(level, msg):
    full_msg = "EDSDK: %s" % msg
    {
        edsdk.ErrorLevel.Debug: debug,
        edsdk.ErrorLevel.Warn: warning,
        edsdk.ErrorLevel.Error: error,
    }[level](full_msg)

edsdk.setErrorLevel(edsdk.ErrorLevel.Debug)
edsdk.setErrorMessageCallback(camera_error_handler)

class Server:
    def _write_message(self, message):
        """
        actually writes the message to the open connection
        """
        raw_data = message.serialize()
        debug("writing outgoing message of type " + message.__class__.__name__)
        self.request.sendall(raw_data)

    def _read_amt(self, byte_count):
        """
        blocks until byte_count bytes have been read
        """