Skip to content

Instantly share code, notes, and snippets.

@j-medland
Last active August 21, 2022 20:42
Show Gist options
  • Save j-medland/f7e2a75c8608d0b8d58df2272f557189 to your computer and use it in GitHub Desktop.
Save j-medland/f7e2a75c8608d0b8d58df2272f557189 to your computer and use it in GitHub Desktop.

Pass IMAQ RGB image from LabVIEW to Python

This code shows an example of passing an IMAQ RGB image to python using the LabVIEW Python Node.

We will use the IMAQ ImageToEDVR.vi to easily convert the IMAQ image into a 3D array of U8s.

The pixel order on the LabVIEW side is ARGB which will magically be reversed to be BGRA (the opencv order) as it is passed to Python.

import numpy as np
import cv2
def show_image(data):
image = np.array(data,dtype=np.uint8)
gray = cv2.cvtColor(image, cv2.COLOR_BGRA2GRAY)
cv2.imshow("This BGRA Image was passed from LabVIEW", image)
cv2.imshow("This is the gray version", gray)
cv2.waitKey(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment