Version 8.8.5
 
Loading...
Searching...
No Matches
/platform/windows/examples/directbinding/irDirectBindingTCPShow.cpp

Windows example: This example shows the usage of the C-style interface to implement a client application displaying data from a TCP streaming server application.

Windows example: This example shows the usage of the C-style interface to implement a client application displaying data from a TCP streaming server application.

#include <iostream>
#include <vector>
#include <memory>
#include "direct_binding.h"
#include "VideoDisplay.h"
VideoDisplay* _display = NULL;
bool _run = true;
int _w;
int _h;
DWORD WINAPI camWorker(LPVOID lpParam)
{
std::vector<unsigned char> img(_w*_h * 3);
while(_run)
{
if(::evo_irimager_get_palette_image(&_w, &_h, &img[0])==0)
{
if(_display) _display->drawCapture(0, 0, _w, _h, 24, &img[0]);
}
}
return 0;
}
int main(int argc, char *argv[])
{
char default_arg[] = "localhost";
char* arg = default_arg;
if(argc<2)
{
std::cout << "usage: " << argv[0] << " <IP>" << std::endl;
return -1;
}
std::cout << "try to connect to " << argv[1] << ":1337" << std::endl;
int ret = ::evo_irimager_tcp_init(argv[1], 1337);
if (ret != 0)
{
std::cout << "error at init" << std::endl;
std::cin.ignore();
return -1;
}
std::cout << "client connected" << std::endl;
{
HANDLE th = CreateThread(NULL, 0, camWorker, NULL, 0, NULL);
int w = _w;
int h = _h;
if (w < 120) w *= 2;
if (h < 120) h *= 2;
_display = new VideoDisplay(w, h);
_display->show();
_display->run();
_run = false;
WaitForSingleObject(th, INFINITE);
CloseHandle(th);
}
return 0;
}
Provides Easy API C-Library Interface.
__IRDIRECTSDK_API__ int evo_irimager_tcp_init(const char *ip, int port)
Initializes the TCP connection to the daemon process (non-blocking)
__IRDIRECTSDK_API__ int evo_irimager_terminate()
Disconnects the camera, either connected via USB or TCP.
__IRDIRECTSDK_API__ int evo_irimager_get_palette_image(int *w, int *h, unsigned char *data)
Accessor to an RGB palette image by reference data format: unsigned char array (size 3 * w * h) r,...
__IRDIRECTSDK_API__ int evo_irimager_get_palette_image_size(int *w, int *h)
Accessor to width and height of false color coded palette image.