[aravis] Re: Getting Thermal Imaging data using python and ARAVIS

  • From: Rens Köhne <rens.kohne@xxxxxxxxx>
  • To: aravis@xxxxxxxxxxxxx
  • Date: Thu, 30 Nov 2017 16:24:03 +0100

Hi Saurabh,

I use Aravis with python, however not with thermal imaging cameras. I use
it with B+W and color cameras.
I have included some example code how to convert an aravis buffer to a numy
array.

I hope the code below helps.

Kind regards,
Rens

---
from gi.repository import Aravis
import numpy as np
import cv2

camera = Aravis.Camera.new(None)
device = camera.get_device()
# set acquisition mode to continuous
device.set_string_feature_value("AcquisitionMode", 'Continuous')
# set camera trigger to software
camera.set_trigger('Software')

stream = camera.create_stream()
camera.start_acquisition()

# lets take 10 images
images = []
for i in range(10):
    camera.software_trigger()
    payload = camera.get_payload()
    stream.push_buffer(Aravis.Buffer.new_allocate(payload))
    image_buffer = stream.pop_buffer()
    data_from_buffer = image_buffer.get_data()
    # depending on the pixel format the stuff below is a bit different
    # for Mono8
    img_data = np.ndarray(buffer=data_from_buffer, dtype=np.uint8,
shape=(camera.get_region()[3], camera.get_region()[2], 1))
    # for Mono12
    img_data = np.ndarray(buffer=data_from_buffer, dtype=np.uint16,
shape=(camera.get_region()[3], camera.get_region()[2], 1))
    # for color you need to de-bayer, for example BayerBG8
    img_data = np.ndarray(buffer=data_from_buffer, dtype=np.uint8,
shape=(camera.get_region()[3], camera.get_region()[2], 1))
    rgb_img_data = cv2.cvtColor(img_data, cv2.COLOR_BAYER_BG2BGR_VNG)

camera.stop_acquisition()

2017-11-28 10:54 GMT+01:00 Saurabh Chatterjee <saurabhsaurc@xxxxxxxxx>:

Hi,

I have connected my FLIR AX5 camera to my computer and used ARAVIS to see
the output. Viewer works fine, test codes work fine. I want to write a
python application which takes this data and does some processing on it.

How can I proceed from here? I checked out the arv-camera-test.py, it
works fine. It returns data as an 'Aravis buffer' What is an aravis buffer?
How can I convert it into data in a convenient format, such as numpy arrays
for example? Can I get some example code?

Thank you for your assistance

Saurabh Chatterjee
Phd, Aerospace Engineering
Indian Institute of Space Science and Technology, Thiruvananthapuram

Other related posts: