code/WPILib/Vision/AxisCamera.cpp
/**
 * Copy the image from private buffer to shared buffer.
 * @param imgBuffer The buffer containing the image
 * @param bufLength The length of the image
 */
Copy the image from private buffer to shared buffer.
@param imgBuffer The buffer containing the image
@param bufLength The length of the image
Copy the image from private buffer to shared buffer . @param imgBuffer The buffer containing the image @param bufLength The length of the image
void AxisCamera::UpdatePublicImageFromCamera(char *imgBuffer, int imgSize)
{
	{
		Synchronized sync(m_protectedImageSem);
		if (m_protectedImageBufferLength < imgSize)
		{
			if (m_protectedImageBuffer != NULL) delete [] m_protectedImageBuffer;
			m_protectedImageBufferLength = imgSize + kImageBufferAllocationIncrement;
			m_protectedImageBuffer = new char[m_protectedImageBufferLength];
			if (m_protectedImageBuffer == NULL)
			{
				m_protectedImageBufferLength = 0;
				return;
			}
		}
		memcpy(m_protectedImageBuffer, imgBuffer, imgSize);
		m_protectedImageSize = imgSize;
	}
	m_freshImage = true;
	SemSet_t::iterator it = m_newImageSemSet.begin();
	SemSet_t::iterator end = m_newImageSemSet.end();
	for (;it != end; it++)
	{
		semGive(*it);
	}
}
void AxisCamera :: UpdatePublicImageFromCamera ( char * imgBuffer , int imgSize ) { { Synchronized sync ( m_protectedImageSem ) ; if ( m_protectedImageBufferLength < imgSize ) { if ( m_protectedImageBuffer != NULL ) delete [ ] m_protectedImageBuffer ; m_protectedImageBufferLength = imgSize + kImageBufferAllocationIncrement ; m_protectedImageBuffer = new char [ m_protectedImageBufferLength ] ; if ( m_protectedImageBuffer == NULL ) { m_protectedImageBufferLength = 0 ; return ; } } memcpy ( m_protectedImageBuffer , imgBuffer , imgSize ) ; m_protectedImageSize = imgSize ; } m_freshImage = true ; SemSet_t :: iterator it = m_newImageSemSet . begin ( ) ; SemSet_t :: iterator end = m_newImageSemSet . end ( ) ; for ( ; it != end ; it ++ ) { semGive ( * it ) ; } }
Copy the image from private buffer to shared buffer.
Copy the image from private buffer to shared buffer .
// Adjust the buffer size if current destination buffer is too small. // Notify everyone who is interested.