SetCompressionQuality
Top  Previous  Next

Description

Sets the compression quality and bitrate for JPEG and H.264 compressed streams.

[C++]
int
 SetCompressionQuality(unsigned int quality, unsigned int bitrate=5000, unsigned int channelIndex=0);


Parameters
[C/C++]
 
[in] unsigned int quality  
Relative value of the compression quality. The higher the quality is, the higher the streaming bandwidth will be. Can be in the following range:  
JPEG compression: 0 - 100  
H.264 compression 0 - 6  
 
[in] unsigned int bitRate  
The value of the bitrate in kbps. Applies only to H.264 compression.  
 
[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 with the compression quality factor of 75.

if (m_pCamera->connect(m_interfaceList.GetCurSel());  
m_pCamera->SetImageCompression(COMPRESSION_JPEG);  
m_pCamera->SetCompressionQuality(75);  
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 in conjunction with SetImageCompression.

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.

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.