Skip to content

A set of utilities for getting NDI frames out of Avkans NDI cameras.

License

Notifications You must be signed in to change notification settings

yatesdr/avkans-ndi-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

avkans-ndi-utils

A class for getting NDI frames out of Avkans NDI cameras in cv2 compatible formats.

Background

AVKans makes an inexpensive line of cameras that now support NewTek NDI protocol. This module is intended to make it easy to connect and get cv2 images from these cameras, and likely other NDI sources. It was originally created as part of an AI face tracker.

This package is not distributed by or endorsed by AVKans or NewTek.

License

This is licensed under the MIT License.

Dependencies

This is a simple wrapper for the NDI Library, and requires it to work. It also uses numpy, and it's recommended to install cv2 if you wish to manipulate the images.

pip install ndi-python
pip install numpy
pip install opencv-python

Color notes

Newtek images come in the standard RGB format, but cv2 normally uses BGR format. You can trivially change between them using cv2 as follows. If your images come out looking like the color channels are mixed, try this.

img=cam.get_cv2_frame()
img=cv2.cvtColor(img,cv2.COLOR_BGR2RGB,img)

Using with other NDI sources

Other NDI sources may need to change the recv object to support the bandwidths they use. You can do this by adding the following line of code back in and choosing the bandwidth based on the NDI options that are supported by your camera.

ndi_recv_create.bandwidth=ndi.RECV_BANDWIDTH_LOWEST

Searching for NDI Sources

The search / discovery function will normally only find sources on the same broadcast domain (i.e. same switch, or hub), but you can connect through a router using the camera IP if needed. This is a limitation of the NewTek discovery protocol and networking in general, and is expected.

Example usage

from avkans-ndi-utils import AvkansCamera
import numpy as np
import cv2


cam1 = AvkansCamera()

# Search for sources (optional - you can directly connect by IP if you don't need discovery)
search_results = cam1.get_sources_as_dict()
print("Search results: ",search_results)

# Connect by IP
result = cam1.connect_by_ip("192.168.35.37")
print(result)

for i in range(30):
    t=time.time()
    frame = cam1.get_cv2_frame()
    print(f"Got frame {i} in ",time.time()-t, " seconds.")

t=time.time()
frame = cam1.get_cv2_frame()
print("Got frame in ",time.time()-t, " seconds.")
print("Frame shape:  ",frame.shape)





About

A set of utilities for getting NDI frames out of Avkans NDI cameras.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages