Example #1
0
void COpenCVgrabber::GenerateEmptyImage(ImgBuffer& img)
{
   MMThreadGuard g(imgPixelsLock_);
   if (img.Height() == 0 || img.Width() == 0 || img.Depth() == 0)
      return;
   unsigned char* pBuf = const_cast<unsigned char*>(img.GetPixels());
   memset(pBuf, 0, img.Height()*img.Width()*img.Depth());
}
void CIDS_uEye::ClearImageBuffer(ImgBuffer& img)
{
   MMThreadGuard g(imgPixelsLock_);
   if (img.Height() == 0 || img.Width() == 0 || img.Depth() == 0)
      return;
   unsigned char* pBuf = const_cast<unsigned char*>(img.GetPixels());
   memset(pBuf, 0, img.Height()*img.Width()*img.Depth());
}
Example #3
0
int CoreCallback::InsertImage(const MM::Device* caller, const ImgBuffer & imgBuf)
{
   Metadata md = imgBuf.GetMetadata();
   unsigned char* p = const_cast<unsigned char*>(imgBuf.GetPixels());
   MM::ImageProcessor* ip = GetImageProcessor(caller);
   if( NULL != ip)
   {
      ip->Process(p, imgBuf.Width(), imgBuf.Height(), imgBuf.Depth());
   }

   return InsertImage(caller, imgBuf.GetPixels(), imgBuf.Width(), 
      imgBuf.Height(), imgBuf.Depth(), &md);
}
Example #4
0
bool ImgBuffer::Compatible(const ImgBuffer& img) const
{
   if (  Height() != img.Height() ||
         Width() != img.Width() ||
         Depth() != img.Depth())
         return false;
   
   return true;
}
Example #5
0
int SpotCamera::NextSequentialImage(ImgBuffer& img)
{
	int nRet = DEVICE_OK;

	unsigned int  bytesPerPixel; // e.g. 4 for RGB
	// values from the device
	unsigned int sourceheight, sourcewidth, sourcedepth;
	char cdepth;
	char *pData;
	pData = 	pImplementation_->GetNextSequentialImage( sourceheight, sourcewidth, cdepth  );


	sourcedepth = (int)cdepth;
	if (3 == sourcedepth)
	{
		bytesPerPixel = 4;
	}
	else
	{
		bytesPerPixel = (int)sourcedepth;
	}
	// EF: set the number of channels depending on the picture returned
	if ( cdepth < 3 ) {
		numberOfChannels_ = 1;
	} else {
		numberOfChannels_ = 4;
	}
	
	const unsigned long bytesRequired = sourceheight*sourcewidth*bytesPerPixel;


	if( (rawBufferSize_ < bytesRequired ) || 
         (sourceheight != (unsigned int)img.Height()) || 
         (sourcewidth != (unsigned int)img.Width()) || 
         (bytesPerPixel !=img.Depth()) )
	{
		this->ResizeImageBuffer( sourcewidth, sourceheight, bytesPerPixel);
	}


	unsigned int destdepth = img.Depth();
	unsigned int destwidth = img.Width();
	unsigned int destheight = img.Height();

	//memset(ptemp, 0, destdepth*destwidth*destheight);

	// handle case where buffer doesn't match returned image size
   /*
	unsigned int xdest, ydest;//, xsource, ysource;
   int roffsetdest, goffsetdest, boffsetdest;
	int roffsetsource, goffsetsource, boffsetsource;
   unsigned int workingwidth = min(destwidth, sourcewidth);
	unsigned int workingheight = min(destheight, sourceheight);
   */

	unsigned char* ptemp = img.GetPixelsRW();

	memset(ptemp,0, destdepth*destwidth*destheight);
	// memcpy for all platforms now
	memcpy( ptemp, pData, destdepth*destwidth*destheight);

	/* Byte arrangement done in SpotDevice 
#ifndef WIN32 // __APPLE__
	memcpy( ptemp, pData, destdepth*destwidth*destheight);
#else


#if 1 // no right left swap needed
	for( ydest = 0; ydest < workingheight; ++ydest)
	{
		for( xdest = 0; xdest < workingwidth; ++xdest)
		{
			roffsetdest = xdest*destdepth + destdepth*ydest*destwidth;
			goffsetdest = roffsetdest + 1;
			boffsetdest = goffsetdest + 1;

			roffsetsource = xdest*sourcedepth + sourcedepth*ydest*sourcewidth;
			goffsetsource = roffsetsource + 1;
			boffsetsource = goffsetsource + 1;
			ptemp[roffsetdest] = pData[roffsetsource];
			if( 1 < destdepth)
			{
			ptemp[goffsetdest] = pData[goffsetsource];			
			ptemp[boffsetdest] = pData[boffsetsource];
			}
		}
	}
#endif


#if 0

	for( ydest = 0; ydest < workingheight; ++ydest)
	{
		for( int xsource  = 0; xsource < workingwidth; ++xsource)
		{
			xdest = workingwidth - 1 - xsource;
			roffsetdest = xdest*destdepth + destdepth*ydest*destwidth;
			goffsetdest = roffsetdest + 1;
			boffsetdest = goffsetdest + 1;

			roffsetsource = xsource*sourcedepth + sourcedepth*ydest*sourcewidth;
			goffsetsource = roffsetsource + 1;
			boffsetsource = goffsetsource + 1;
			ptemp[roffsetdest] = pData[roffsetsource];
			if( 1 < destdepth)
			{
				ptemp[goffsetdest] = pData[goffsetsource];			
				ptemp[boffsetdest] = pData[boffsetsource];
			}
		}
	}
#endif
	//img.SetPixels(ptemp);
#endif 
*/
	return nRet;

}