Update of /cvsroot/playerstage/code/player/server/drivers/blobfinder/cmvision
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7495
Modified Files:
Tag: release-2-0-patches
P2CMV.cc
Log Message:
applied patch 1704470
Index: P2CMV.cc
===================================================================
RCS file:
/cvsroot/playerstage/code/player/server/drivers/blobfinder/cmvision/P2CMV.cc,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -C2 -d -r1.26 -r1.26.2.1
*** P2CMV.cc 16 Nov 2005 00:56:01 -0000 1.26
--- P2CMV.cc 24 Apr 2007 21:30:19 -0000 1.26.2.1
***************
*** 115,118 ****
--- 115,119 ----
#include <libplayercore/playercore.h>
#include <libplayercore/error.h>
+ #include <libplayerjpeg/playerjpeg.h>
#include "conversions.h"
***************
*** 139,142 ****
--- 140,144 ----
uint16_t mHeight; // the image dimensions
uint8_t* mImg;
+ uint8_t* mTmp;
const char* mColorFile;
***************
*** 157,160 ****
--- 159,163 ----
// constructor
CMVisionBF(ConfigFile* cf, int section);
+ virtual ~CMVisionBF();
// This method will be invoked on each incoming message
virtual int ProcessMessage(MessageQueue* resp_queue,
***************
*** 185,188 ****
--- 188,192 ----
mHeight(0),
mImg(NULL),
+ mTmp(NULL),
mColorFile(NULL),
mCameraDev(NULL),
***************
*** 200,206 ****
--- 204,222 ----
}
+ CMVisionBF::~CMVisionBF()
+ {
+ if (mVision) delete mVision;
+ if (mImg) delete []mImg;
+ if (mTmp) delete []mTmp;
+ }
+
int
CMVisionBF::Setup()
{
+ if (mVision)
+ {
+ PLAYER_ERROR("CMVision server already initialized");
+ return -1;
+ }
printf("CMVision server initializing...");
fflush(stdout);
***************
*** 217,221 ****
}
! mVision = new CMVision;
// clean our data
memset(&mData,0,sizeof(mData));
--- 233,237 ----
}
! mVision = new CMVision();
// clean our data
memset(&mData,0,sizeof(mData));
***************
*** 235,243 ****
StopThread();
! // Unsubscribe from the laser
this->mCameraDev->Unsubscribe(this->InQueue);
! delete mVision;
! delete mImg;
puts("CMVision server has been shutdown");
--- 251,258 ----
StopThread();
! // Unsubscribe from the camera
this->mCameraDev->Unsubscribe(this->InQueue);
! delete mVision; mVision = NULL;
puts("CMVision server has been shutdown");
***************
*** 266,274 ****
CMVisionBF::ProcessImageData()
{
// this shouldn't change often
if ((mData.width != mWidth) || (mData.height != mHeight))
{
- //printf("CMVision server initializing...");
- fflush(stdout);
if(!(mVision->initialize(mWidth, mHeight)))
{
--- 281,288 ----
CMVisionBF::ProcessImageData()
{
+ assert(mVision);
// this shouldn't change often
if ((mData.width != mWidth) || (mData.height != mHeight))
{
if(!(mVision->initialize(mWidth, mHeight)))
{
***************
*** 401,427 ****
this->mCameraAddr))
{
// we can't quite do this so easily with camera data
// because the images are different than the max size
//assert(hdr->size == sizeof(player_camera_data_t));
! player_camera_data_t* camera_data;
! camera_data = reinterpret_cast<player_camera_data_t *>(data);
!
! mWidth = camera_data->width;
! mHeight = camera_data->height;
! if (NULL == mImg)
! {
! // we need to allocate some memory
! mImg = new uint8_t[mWidth*mHeight*2];
! }
! else
{
// now deal with the data
! rgb2uyvy(camera_data->image, mImg, mWidth*mHeight);
! }
!
! // we have a new image,
! ProcessImageData();
return(0);
}
--- 415,456 ----
this->mCameraAddr))
{
+ // Lock();
// we can't quite do this so easily with camera data
// because the images are different than the max size
//assert(hdr->size == sizeof(player_camera_data_t));
! player_camera_data_t* camera_data = reinterpret_cast<player_camera_data_t
*>(data);
! uint8_t* ptr;
! assert(camera_data);
! assert(camera_data->bpp == 24);
! if ((camera_data->width) && (camera_data->height))
{
+ if ((mWidth != camera_data->width) || (mHeight != camera_data->height)
|| (!mImg) || (!mTmp))
+ {
+ mWidth = camera_data->width;
+ mHeight = camera_data->height;
+ if (mImg) delete []mImg; mImg = NULL;
+ if (mTmp) delete []mTmp; mTmp = NULL;
+ // we need to allocate some memory
+ if (!mImg) mImg = new uint8_t[mWidth*mHeight*2];
+ if (!mTmp) mTmp = new uint8_t[mWidth*mHeight*3];
+ }
+ ptr = camera_data->image;
+ if (camera_data->compression == PLAYER_CAMERA_COMPRESS_JPEG)
+ {
+ jpeg_decompress((unsigned char*)mTmp,
+ PLAYER_CAMERA_IMAGE_SIZE,
+ camera_data->image,
+ camera_data->image_count
+ );
+ ptr = mTmp;
+ }
// now deal with the data
! rgb2uyvy(ptr, mImg, mWidth*mHeight);
+ // we have a new image,
+ ProcessImageData();
+ }
+ // Unlock();
return(0);
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit