Exemplo n.º 1
0
	def _captureBayer(shutter_speed):
		camera = None
		try:
			camera = PiCamera()
			_setup_camera(camera, _max_resolution, shutter_speed, _iso)
			
			rawCapture = PiBayerArray(camera)
			print('capture...')
			bayerCapture = PiBayerArray(camera)
			camera.capture(bayerCapture, 'jpeg', bayer=True) # grab the 10 bit resolution with the raw bayer data

			imageBayer = bayerCapture.demosaic()
			print('done')
			
		except:
			if camera is None:
				raise Exception('Failed to initialize PiCamera.')
			else:
				raise Exception('Failed to capture image.')
			
		finally:
			if camera is not None:
				camera.close()
		
		return imageBayer
Exemplo n.º 2
0
    def _captureBayer(shutter_speed):
        camera = None
        try:
            camera = PiCamera()
            _setup_camera(camera, _max_resolution, shutter_speed, _iso)

            rawCapture = PiBayerArray(camera)
            print("capture...")
            bayerCapture = PiBayerArray(camera)
            camera.capture(bayerCapture, "jpeg", bayer=True)  # grab the 10 bit resolution with the raw bayer data

            imageBayer = bayerCapture.demosaic()
            print("done")

        except:
            if camera is None:
                raise Exception("Failed to initialize PiCamera.")
            else:
                raise Exception("Failed to capture image.")

        finally:
            if camera is not None:
                camera.close()

        return imageBayer
Exemplo n.º 3
0
class CamServer_CaptureHandler():
    def __init__(self):
        self.cam = PiCamera()
        self.arr = PiBayerArray(self.cam)

    def capture(self):
        logging.info('Capturing frame from camera')
        self.cam.capture(self.arr, 'jpeg', bayer=True)
        return self.arr.demosaic()
Exemplo n.º 4
0
camera.resolution = (2592, 1944)  # max. resolution
camera.framerate = 1

camera.exposure_mode = 'off'
camera.shutter_speed = 50000  # microseconds
print("shutter", camera.shutter_speed)

g = camera.awb_gains  # get some reasonable gains

camera.awb_mode = 'off'
camera.awb_gains = (1, 1)  # (red, blue)
camera.iso = 10
print("iso", camera.iso)

# raw bayer capture
bayerCapture = PiBayerArray(camera)
camera.capture(
    bayerCapture, 'jpeg',
    bayer=True)  # grab the 10 bit resolution with the raw bayer data

imageBayer = bayerCapture.demosaic()
#imageBayer = imageBayer / 4
#imageBayer = imageBayer.astype(np.uint8)
print(imageBayer)

#camera.capture(rawCapture, format="yuv") # using yuv instead of rgb
#camera.capture(rawCapture, format="bgr") # using yuv instead of rgb
image = imageBayer

imsave('bayer.tiff', image)
            if args.settings_file is None:
                # Set the camera up so white illumination doesn't saturate
                cr.auto_expose_to_white(camera, led)
            else:
                cr.restore_settings(camera,
                                    args.settings_file,
                                    ignore=["lens_shading_table"])

            print("Acquiring white image")
            calibration_image = os.path.join(output_dir,
                                             "calibration_image.jpg")
            led.set_rgb(255, 255, 255)
            time.sleep(1)
            camera.capture(calibration_image, bayer=True)

        with PiBayerArray(camera) as a, \
             open(calibration_image, mode="rb") as jpg:
            a.write(jpg.read())
            a.flush()
            raw_image = a.array.copy()

        # Now we need to calculate a lens shading table that would make this flat.
        # raw_image is a 3D array, with full resolution and 3 colour channels.  No
        # demosaicing has been done, so 2/3 of the values are zero (3/4 for R and B
        # channels, 1/2 for green because there's twize as many green pixels).
        channels = channels_from_bayer_array(raw_image)
        lens_shading_table = lst_from_channels(channels)
        cr.save_settings(
            camera, os.path.join(output_dir,
                                 "camera_settings_calibration.yaml"))
Exemplo n.º 6
0
# fix camera parameters
camera.resolution = (2592,1944) # max. resolution
camera.framerate = 1

camera.exposure_mode = 'off'
camera.shutter_speed = 50000 # microseconds
print("shutter", camera.shutter_speed)

g = camera.awb_gains # get some reasonable gains

camera.awb_mode = 'off'
camera.awb_gains = (1,1) # (red, blue)
camera.iso = 10
print("iso", camera.iso)

# raw bayer capture
bayerCapture = PiBayerArray(camera)
camera.capture(bayerCapture, 'jpeg', bayer=True) # grab the 10 bit resolution with the raw bayer data

imageBayer = bayerCapture.demosaic()
#imageBayer = imageBayer / 4
#imageBayer = imageBayer.astype(np.uint8)
print(imageBayer)

#camera.capture(rawCapture, format="yuv") # using yuv instead of rgb
#camera.capture(rawCapture, format="bgr") # using yuv instead of rgb
image = imageBayer

imsave('bayer.tiff', image)
Exemplo n.º 7
0
 def __init__(self):
     self.cam = PiCamera()
     self.arr = PiBayerArray(self.cam)