1 #include <Base/Image/ImageIO.hh>
4 #include <VideoSource/VideoSource_Kinect2.hh>
5 #include <NetworkComm/CScommServer.hh>
10 int main(
int argc,
char *argv[])
12 int devID = argc > 1 ? atoi(argv[1]) : 0;
13 int portID = argc > 2 ? atoi(argv[2]) : 8090;
16 cam.
SetMode(VideoSource_Kinect2::depthAndIr);
18 std::cout <<
"Error: Failed to open device " << devID <<
"!" << std::endl;
21 std::cout <<
"Opened device " << devID << std::endl;
24 std::cout <<
"Initializing capture" << std::endl;
30 std::cout <<
"Starting server" << std::endl;
38 std::cout <<
"Wait for connections at port " << portID << std::endl;
41 unsigned char *data =
new unsigned char[byteSize*2];
42 unsigned char *datair = data + byteSize;
50 server.
SendMsg(
"img", (
char*)data, 2*byteSize);
53 std::cout <<
"Closing device" << std::endl;
void SetMode(Kinect2Mode mode)
virtual int PostGrab()
Stop grabbing.
virtual int GrabSingleDepth(BIAS::Camera< float > &image)
grab the depth image (slow).
Use the Kinect2 class to grab images from the Microsoft Kinect2.
virtual int InitDepthImage(BIAS::ImageBase &Image)
kinect 2 depth image will be 512x424, float in Millimeters
virtual int GrabSingleIR(BIAS::Camera< float > &image)
grab the raw ir data dump (very fast).
unsigned int GetSizeByte() const
returns the nr.
virtual int InitIrImage(BIAS::ImageBase &Image)
kinect 2 ir image will be 512x424, single channel unsigned char
int RegisterMsg(std::string msgName, EdataType dataType, int amount=1)
only registered msgs are accepted by commPartners Register a msg with this functions.
void WaitForConnections(unsigned int port=D_CS_DEFAULT_PORT)
Init function, returns instantly and enables the server to accept connections on the given port ...
void SetVerbose(bool on)
gives some information about establising conn, and disconnecting etc.
class for sending/receiving data between clients and serversOnly registered msgs will be accepted at ...
virtual int PreGrab()
Start grabbing.
virtual int OpenDevice()
Opens first device found, OpenDevice(0)
virtual int CloseDevice()
Close device, if no other kinect cameras are in use, context is deleted (i.e. close usb bus connectio...
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
int SendMsg(const std::string &msgName, std::vector< float > &floatData)
sends msg msgName to all connected commPartners.