Code Monkey home page Code Monkey logo

avkans-ndi-utils's Introduction

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)





avkans-ndi-utils's People

Contributors

yatesdr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.