SendImage
Top  Previous  Next

Description

Streams the specified image frame to the network.

[C++]
int
 SendImage(const char* frame, unsigned int channelIndex = 0, unsigned int sizeY = 0);


Parameters
[C/C++]
 
[in] const char* frame  
Pointer to the beginning of the image data (top left pixel). The image data format must be compatible with the one set via SetImageSize and SetPixelFormat.  
 
[in] unsigned int channelIndex  
Index of the associated stream channel. Possible values are 0 or 1.  
 
[in] unsigned int sizeY  
The vertical size of the frame to send. Can be used for simulating a line scan camera with a variable frame size. If zero or omitted, the full-size frame will be sent.  


Return Values

S_OK  
Success  
E_FAIL  
Failure  
 

Example


This fragment of code generates sequential monochrome video frames with a random pattern and sends them over the network

if (m_pCamera->connect(m_interfaceList.GetCurSel());  
m_exitThread = false;  
m_thread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)videoGenThread, this, 0, NULL);  
 
void CGigemuDlg::videoGenerator()   
{  
int width;  
int height;  
char buffer[MAXWIDTH*MAXHEIGHT];  
char *ptr;  
int i=0;  
while (!m_exitThread)   
{  
m_pCamera->LockFormat();  
width=m_pCamera->GetWidth();  
height=m_pCamera->GetHeight();  
for (ptr=buffer; ptr < buffer+width*heigh; ptr++)  
 *ptr=i++;  
m_pCamera->SendImage(buffer);  
Sleep(20);  
}  
}  


Remarks

This function is typically called in a cycle to stream a series of image frames from the virtual camera to the network. The camera must be in the connected state and the acquisition must have been started by a client application.

If the SendImage cycle is called before the acquisition is started by the client, the LockFormat method must be called prior to calling SendImage in order to lock the execution of the thread until the AcquisitionStart command is issued by the client. Alternatively you can use the Write Callback to intercept AcquisitionStart and AcquisitionStop commands from the client application and to synchronize them with the beginning and end of the image transfer cycle.

Each image streamed with this function will contain a timestamp per GigE Vision standard indicating the exact time at which the image was generated. Depending on the Timer Mode, the timestamp will be reported either in the astronomical time or time elapsed from the start of the virtual camera application.

Note the channelIndex parameter should be used only if your virtual camera must support multiple streaming channels. For a regular GigE Vision transfer this parameter should remain in its default zero value.