I’ve created python script which takes image frames from a webcam, runs some opencv machine learning operations on each image and prints out a number for each frame. I would now like to use this script in TouchDesigner.
I’m trying to solve a few problems:
How do I access images from the VideoDeviceIn TOP in a python script text DAT?
How do I output variables from a python script text DAT so that they can be accessed in other scripts or operators?
Here is an abbreviate version of my script
import cv2
# need to change this so it takes frame from VideoDeviceIn TOP
cap = cv2.VideoCapture(0)
_ret, frame = cap.read()
# Very abbreviate. Here I run a bunch of custom OpenCV operations which result in an integer prediction
digit = resultOfOpenCVOperations
# I would like to pass the digit as ouput to be accessed by other operators
print(digit)
In the past I’ve just written to and read from file for these kinds of operations, but this approach should have some potential for you.
In terms of sending variables to other scripts you have a number of options - you can always write them to a table, or a constant CHOP. You might also look into storage as a way to solve this problem as well. Probably the more useful approach here would be to author an extension or python module to keep things running smoothly.