PointSpread® Vidu™ Software Development Kit  V1
Vidu SDK
Python Wrapper

We use pybind11 tool to export Vidu API classes and functions to python through a dynamically loadable module, e.g. the pyvidu.cpython-38-x86_64-linux-gnu.so in Linux or pyvidu.cp38-win_amd64.pyd for Windows. The class PDdevice and PDstream are well exposed to python. Thus, developers can use a Python-ish way to control the Okulo camera by simply executing import pyvidu. Below we show a simple script that also retrieves the camera's intrinsic and extrinsic parameters as we have done before.

import pyvidu as vidu
import cv2 as cv
intrinsic = vidu.intrinsics()
extrinsic = vidu.extrinsics()
device = vidu.PDdevice()
if not device.init():
print("device init failed")
exit(-1)
print("device init succeed")
stream_num = device.getStreamNum()
print("stream_num = {}\n".format(stream_num))
for i in range(stream_num):
stream = vidu.PDstream(device, i)
suc= stream.init()
streamName = stream.getStreamName()
if not suc:
print("stream {} init failed\n".format(i))
else:
print("stream {} init success\n".format(i))
while True:
mats = stream.getPyMat()
for i, mat in enumerate(mats):
cv.imshow("%s: %i" %(streamName, i), mat)
key = cv.waitKey(1)
if key & 0xFF == ord('q'):
break
suc = stream.getCamPara(intrinsic, extrinsic)
vidu.print_intrinsics(intrinsic)
vidu.print_extrinsics(extrinsic)
print("finish stream {}\n".format(i))
cv.destroyAllWindows()
print("all set\n")

We import the pyvidu and opencv library, and initialize empty intrinsic, extrinsic and device object through vidu.intrinsics(), vidu.extrinsics(), and vidu.PDdevice(). By device.init(), the program tries to connect to a camera. If there is a powered-up camera connected to the host computer, we will step forward to device.getStreamNum(). Then we initialize the PDstream object stream correspondingly to each stream and get their intrinsics and extrinsics by stream.getCamPara(intrinsic, extrinsic). The whole procedure is the same as in its C++ version code in code sample