SetImageCompression
Top  Previous  Next

Description

Sets the image compression mode.

[C++]
int
 SetImageCompression(unsigned short compression,  unsigned int channelIndex=0);


Parameters
[C/C++]
 
[in] unsigned short compression  
Image compression mode. Can be one of the following values:  
COMPRESSION_NONE - virtual camera will stream uncompressed images  
COMPRESSION_JPEG - virtual camera will stream JPEG compressed images  
COMPRESSION_H264 - virtual camera will stream H.264 compressed video  
 
[in] unsigned int channelIndex  
Index of the associated stream channel. Possible values are 0 or 1.  
 

Return Values


S_OK  
Success  
E_FAIL  
Failure  
 

Example

This fragment of code generates sequential video frames with a random RGB pattern and sends them over the network as JPEG images.

if (m_pCamera->connect(m_interfaceList.GetCurSel());  
m_pCamera->SetImageCompression(COMPRESSION_JPEG);  
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*3];  
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; i++)  
{  
 *ptr++=i; *ptr++=i/2; *ptr++=i%255;  
m_pCamera->SendImage(buffer);  
Sleep(20);  
}  
}  


Remarks


This method is used to switch the virtual camera to a compressed streaming mode per GigE Vision 2.0 specifications. When JPEG or H.264 payload type is selected, the SendImage function will apply an internal compression to image frames before streaming them to the network. To adjust compression settings, use SetCompressionQuality.

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.

Note that only 8-bit monochrome and RGB images can be compressed. You need to make sure that image buffer submitted to SendImage have data in a correct format.

If your computer has an Intel graphics card, GigESim will use hardware acceleration for H.264 compression. This will allow you to achieve a higher image resolution and/or frame rate as opposed to the software compression.

Note that a GigE Vision client must be able to decompress incoming image frames in real time in order to display and process compressed video generated by GigESim. We recommend using our ActiveGigE SDK
which supports both JPEG and H.264 decompression on the fly.