Created
January 22, 2014 20:11
-
-
Save mguijarr/8566477 to your computer and use it in GitHub Desktop.
Example Python code to read frames from Prosilica camera using Lima
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Lima import Core, Prosilica | |
from Qub.CTools import pixmaptools | |
# initialize Lima and connect to camera | |
prosilica = Prosilica.Camera("192.168.1.2") | |
interface = Prosilica.Interface(prosilica) | |
control = Core.CtControl(interface) | |
video = control.video() | |
video.setExposure(1.0/25.0) | |
# start frames acquisition | |
video.startLive() | |
# the easiest is to periodically call this function | |
# to get the latest frame (like, every 40 milliseconds), | |
# passing the 'video' Lima object as argument | |
def get_last_frame(video): | |
image = video.getLastImage() | |
raw_buffer = image.buffer() | |
# by default, images returned by the Prosilica | |
# opened with Lima are Bayer format, 16 bits ; | |
# it has to be converted to RGB in a QImage for | |
# Qt to be able to display it ; | |
# we use Qub for this task | |
scaling = pixmaptools.LUT.Scaling() | |
scaling.autoscale_plus_minus_sigma(raw_buffer, | |
image.width(), image.height(), | |
pixmaptools.LUT.Scaling.BAYER_RG16, 3) | |
validFlag,qimage = pixmaptools.LUT.raw_video_2_image(raw_buffer, | |
image.width(), | |
image.height(), | |
pixmaptools.LUT.Scaling.BAYER_RG16, | |
scaling) | |
# other formats than Bayer 16 can be selected: | |
# using "video.setMode", eg. video.setMode(Core.BAYER_RG16) | |
# this has to be set prior to starting acquisition. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment