Esempio n. 1
0
        def found_camera(cam):
            if cam is None:
                # try again
                nonlocal tries_left
                tries_left -= 1
                if tries_left >= 1:
                    debug("Unable to find camera, waiting a second and trying again")
                    time.sleep(1)
                    edsdk.getFirstCamera(found_camera)
                else:
                    debug("Unable to find camera, giving up.")
                    return
            else:
                debug("Found camera")

                cam.setMeteringMode(edsdk.MeteringMode.SpotMetering)
                cam.setAFMode(edsdk.AFMode.ManualFocus)
                cam.setDriveMode(edsdk.DriveMode.SingleFrameShooting)

                def firstPicCallback(trash):
                    os.remove(trash)

                    def takePictureCallback(pic_file):
                        debug("got picture callback")
                        # create a thumbnail
                        make_thumbnail(pic_file, pic_file+".thumb", 90)
                        # notify change
                        send_directory_list()
                    cam.setPictureCompleteCallback(takePictureCallback)
                    global camera
                    camera = cam

                    global live_view_thread
                    live_view_thread = make_thread(run_live_view_thread, "live_view")
                    live_view_thread.start()
                cam.setPictureCompleteCallback(firstPicCallback)

                def incantation():
                    debug("starting incantation")
                    time.sleep(0.5)
                    debug("incantation start live view")
                    cam.startLiveView()
                    time.sleep(3)
                    debug("incantation grab live view frame")
                    cam.grabLiveViewFrame()
                    time.sleep(0.5)
                    debug("incantation auto focus")
                    cam.autoFocus()
                    time.sleep(2)
                    debug("incantation take picture")
                    cam.takePicture(os.path.join(settings['DATA_FOLDER'], 'trash.jpg'))
                make_thread(incantation, "incantation").start()
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
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)