How to use the gphoto2.GP_FILE_TYPE_NORMAL function in gphoto2

To help you get started, we’ve selected a few gphoto2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jim-easterbrook / python-gphoto2 / examples / wait-for-event.py View on Github external
def main():
    # Init camera
    camera = gp.Camera()
    camera.init()
    timeout = 3000 # miliseconds
    while True:
        event_type, event_data = camera.wait_for_event(timeout)
        if event_type == gp.GP_EVENT_FILE_ADDED:
            cam_file = camera.file_get(
                event_data.folder, event_data.name, gp.GP_FILE_TYPE_NORMAL)
            target_path = os.path.join(os.getcwd(), event_data.name)
            print("Image is being saved to {}".format(target_path))
            cam_file.save(target_path)
    return 0
github greiginsydney / Intervalometerator / Raspberry Pi / intvlm8r.py View on Github external
app.logger.debug('No files found')
        return 1
    app.logger.debug('Copying files...')

    if not os.path.isdir(PI_PHOTO_DIR):
        os.makedirs(PI_PHOTO_DIR)

    for path in camera_files:
        sourceFolderTree, imageFileName = os.path.split(path)
        dest = CreateDestPath(sourceFolderTree, PI_PHOTO_DIR)
        dest = os.path.join(dest, imageFileName)
        if dest in computer_files:
            continue
        app.logger.debug('Copying %s --> %s' % (path, dest))
        camera_file = gp.check_result(gp.gp_camera_file_get(
            camera, sourceFolderTree, imageFileName, gp.GP_FILE_TYPE_NORMAL))
        gp.check_result(gp.gp_file_save(camera_file, dest))
    return 0
github jim-easterbrook / python-gphoto2 / examples / capture-image.py View on Github external
def main():
    logging.basicConfig(
        format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING)
    callback_obj = gp.check_result(gp.use_python_logging())
    camera = gp.Camera()
    camera.init()
    print('Capturing image')
    file_path = camera.capture(gp.GP_CAPTURE_IMAGE)
    print('Camera file path: {0}/{1}'.format(file_path.folder, file_path.name))
    target = os.path.join('/tmp', file_path.name)
    print('Copying image to', target)
    camera_file = camera.file_get(
        file_path.folder, file_path.name, gp.GP_FILE_TYPE_NORMAL)
    camera_file.save(target)
    subprocess.call(['xdg-open', target])
    camera.exit()
    return 0
github greiginsydney / Intervalometerator / Raspberry Pi / www / intvlm8r.py View on Github external
config.write(config_file)
            app.logger.debug('Added deleteAfterCopy flag to the INI file, after error : ' + str(e))
        except Exception as e:
            app.logger.debug('Exception thrown trying to add deleteAfterCopy to the INI file : ' + str(e))
        deleteAfterCopy = False
    
    for path in camera_files:
        sourceFolderTree, imageFileName = os.path.split(path)
        dest = CreateDestPath(sourceFolderTree, PI_PHOTO_DIR)
        dest = os.path.join(dest, imageFileName)
        if dest in computer_files:
            continue
        app.logger.debug('Copying {0} --> {1}'.format(path, dest))
        try:
            camera_file = gp.check_result(gp.gp_camera_file_get(
                camera, sourceFolderTree, imageFileName, gp.GP_FILE_TYPE_NORMAL))
            copyOK = gp.check_result(gp.gp_file_save(camera_file, dest))
            if ((copyOK >= gp.GP_OK) and (deleteAfterCopy == True)):
                gp.check_result(gp.gp_camera_file_delete(camera, sourceFolderTree, imageFileName))
                app.logger.debug('Deleted {0}/{1}'.format(sourceFolderTree, imageFileName))
        except Exception as e:
            app.logger.debug('Exception in copy_files: ' + str(e))
    return 0
github jim-easterbrook / python-gphoto2 / examples / wait-for-event-oo.py View on Github external
def main():
    # Init camera
    camera = gp.Camera()
    camera.init()
    timeout = 3000 # miliseconds
    while True:
        event_type, event_data = camera.wait_for_event(timeout)
        if event_type == gp.GP_EVENT_FILE_ADDED:
            cam_file = camera.file_get(
                event_data.folder, event_data.name, gp.GP_FILE_TYPE_NORMAL)
            target_path = os.path.join(os.getcwd(), event_data.name)
            print("Image is being saved to {}".format(target_path))
            cam_file.save(target_path)
    return 0
github jim-easterbrook / python-gphoto2 / examples / read-exif-gexiv2.py View on Github external
def get_file_exif_normal(camera, path):
    # a 32k buffer is large enough for my Canon EOS 100D and A1100 IS
    # use a bigger buffer if you get "GExiv2: unsupported format" errors
    buf = bytearray(32 * 1024)
    folder, file_name = os.path.split(path)
    camera.file_read(folder, file_name, gp.GP_FILE_TYPE_NORMAL, 0, buf)
    md = GExiv2.Metadata()
    md.open_buf(buf)
    return md
github jim-easterbrook / python-gphoto2 / examples / time_lapse.py View on Github external
template = os.path.join(WORK_DIR, 'frame%04d.jpg')
    next_shot = time.time() + 1.0
    count = 0
    with configured_camera() as camera:
        while True:
            try:
                empty_event_queue(camera)
                while True:
                    sleep = next_shot - time.time()
                    if sleep < 0.0:
                        break
                    time.sleep(sleep)
                path = camera.capture(gp.GP_CAPTURE_IMAGE)
                print('capture', path.folder + path.name)
                camera_file = camera.file_get(
                    path.folder, path.name, gp.GP_FILE_TYPE_NORMAL)
                camera_file.save(template % count)
                camera.file_delete(path.folder, path.name)
                next_shot += INTERVAL
                count += 1
            except KeyboardInterrupt:
                break
    subprocess.check_call(['ffmpeg', '-r', '25',
                           '-i', template, '-c:v', 'h264', OUT_FILE])
    for i in range(count):
        os.unlink(template % i)
    return 0
github jim-easterbrook / python-gphoto2 / examples / focus-gui.py View on Github external
def _do_capture(self):
        # capture actual image
        OK, camera_file_path = gp.gp_camera_capture(
            self.camera, gp.GP_CAPTURE_IMAGE)
        if OK < gp.GP_OK:
            print('Failed to capture')
            self.running = False
            return
        camera_file = self.camera.file_get(
            camera_file_path.folder, camera_file_path.name,
            gp.GP_FILE_TYPE_NORMAL)
        self._send_file(camera_file)
github jim-easterbrook / python-gphoto2 / examples / read-exif-exifread.py View on Github external
def read(self, size=None):
        if size is None or size < 0:
            size = self._size - self._ptr
        if (self._ptr < self._buf_ptr or
                self._ptr >= self._buf_ptr + self._buf_len):
            self._buf_ptr = self._ptr - (self._ptr % len(self._buf))
            self._buf_len = self._camera.file_read(
                self._folder, self._file_name, gp.GP_FILE_TYPE_NORMAL,
                self._buf_ptr, self._buf)
        offset = self._ptr - self._buf_ptr
        size = min(size, self._buf_len - offset)
        self._ptr += size
        return self._buf[offset:offset + size]
github jim-easterbrook / python-gphoto2 / examples / cam-conf-view-gui.py View on Github external
def do_capture_image(camera):
    # adjust camera configuratiuon
    cfg = camera.get_config()
    capturetarget_cfg = cfg.get_child_by_name('capturetarget')
    capturetarget = capturetarget_cfg.get_value()
    capturetarget_cfg.set_value('Internal RAM')
    camera.set_config(cfg)
    # do capture
    path = camera.capture(gp.GP_CAPTURE_IMAGE)
    print('capture cam path: {} {}'.format(path.folder, path.name))
    camera_file = camera.file_get(
        path.folder, path.name, gp.GP_FILE_TYPE_NORMAL)
    # saving of image implied in current directory:
    camera_file.save(path.name)
    camera.file_delete(path.folder, path.name)
    # reset configuration
    capturetarget_cfg.set_value(capturetarget)
    camera.set_config(cfg)
    return path.name