Ncam Reality
...
Custom Integration
SDK Lite
12 min
the ncamsdk lite is provided as a solution for integrations into new or custom render engines it is a more streamlined and straightforward protocol to implement than the full ncamsdk protocol yet provides more information than a basic freed implementation camera telemetry data is streamed on a per frame basis for the following types camera pose position and orientation , packet number and frame timecode, normalized and mapped values for focus, iris and zoom (as per the values displayed on the barrel), nodal shift in meters, lens parametric model, including focal length, optical center and distortion coefficients data stream in it's current implementation, the lite protocol can be streamed via udp and serial udp parameters the udp data stream can be configured to either broadcast or unicast and the destination ip and port are fully configurable via the ncam reality full ui preferences by default, sdk lite packets will be sent on port 3004 serial parameters the serial device could be configured as well the serial parameters are configured according to the table below parameter value baud rate 115200 data bits 8 parity none stop bits 1 flow control none the total size of each packet provided by the sdk lite is smaller that the typical 1500 bytes used in udp communication and its format will conform to the specification described by the version of the sdk lite protocol packet format after a 2 characters control flag (0x0a, 0x0d), the next 8 bytes will always be fixed whatever the version of the sdk lite protocol they define the version of the protocol that is streamed and the length of the dynamic section in bytes the packets must be checked against their checksum at arrival this is achieved by computing the sum of all bytes as int8 t starting with the checksum and ending with the last byte of the dynamic section which length is given by #3 a valid packet would sum to zero total size of a packet is 134 bytes for a 1080p60 video signal, the required bandwidth is 60x134 = 8040 bytes/sec so under 8kb/sec description of packets packet number a counter of sent packets since the sdk lite began streaming timecode the sdi source’s timecode translation the translation vector\[3] in meters using eigen , a cross platform header only c++ library, we can apply the transformation as follows \#include \<eigen/dense> eigen vector3f rodriguesvec(rotx, roty, rotz); // rotx, roty, and rotz are read directly from sdklite eigen angleaxisf angleaxis(rodriguesvec norm(), rodriguesvec normalized()); eigen matrix3f rotationmatrix = angleaxis torotationmatrix(); eigen vector3f translationvec(tx, ty, tz); // tx, ty and tz are read directly from sdklite // rotation must be applied before adding the translation to get a position vector3f position = rotationmatrix eigen vector3f(0, 0, 0) + translationvec; rotation the rotation uses a compact vector\[3] rodrigues representation \ the angle of rotation is given by the module of the input vector \ the axis of rotation is given by the normalized input vector opencv provides a convenient method to convert to and from a 3x3 rotation matrix void rodrigues(inputarray src, outputarray dst, outputarray jacobian=noarray()) alternatively the sophus library provides similar implementation to instantiate rotation matrix from the vector\[3] representation eigen , a cross platform header only c++ library can handle this vector and produce a rotation matrix and euler angles via the following \#include \<eigen/dense> eigen vector3f rodriguesvec(rotx, roty, rotz); // rotx, roty, and rotz are read directly from sdklite eigen angleaxisf angleaxis(rodriguesvec norm(), rodriguesvec normalized()); eigen matrix3f rotationmatrix = angleaxis torotationmatrix(); // you will need to choose the angle order as arguments eigen vector3f eulerangles = rotinv eulerangles( ); normalized fiz focus, iris and zoom encoder values normalized between 0 0 and 1 0 mapped fiz world scale values for focus (in meters), iris (in t stops) and zoom (in mm) from the values engraved on the lens barrels nodal shift the offset in meters from the camera sensor’s image plane to the nodal point of the lens lens parameters this is a vector\[15] with 3 distinct sections we currently support the following simplified brown conrady model x = x (1+k1 x r^2 + k2 r^4); y = y (1+k1 x r^2 + k2 r^4); where r^2 = x^2 + y^2; the distortion parameters are taking place on a normalized space such that a radius of 1 of r means half diagonal of the image lensparameters\[0] is the horizontal focal length, normalized by the image width; lensparameters\[1] is the vertical focal length, normalized by the image height; lensparameters\[2] is the horizontal optical center, normalized by the image width, origin is left; lensparameters\[3] is the vertical optical center, normalized by the image height, origin is top; lensparameters\[4] is distortion parameter k1; lensparameters\[5] is distortion parameter k2; lensparameters\[6] is undistortion parameter k1; lensparameters\[7] is undistortion parameter k2;