Process image in epics layer when arrive a new frame from device
This commit is contained in:
@@ -488,6 +488,7 @@ epicsTimeStamp imageStamp;
|
||||
int callback;
|
||||
int acquireStatusError = 0;
|
||||
int eventStatus=0;
|
||||
uint64_t prevAcquisitionCount = 0;
|
||||
epicsTimeStamp startTime; // endTime;
|
||||
DCAMCAP_TRANSFERINFO captransferinfo;
|
||||
|
||||
@@ -515,6 +516,7 @@ epicsTimeStamp imageStamp;
|
||||
acquire = 1;
|
||||
/* Get the current time */
|
||||
epicsTimeGetCurrent(&startTime);
|
||||
prevAcquisitionCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,55 +533,60 @@ epicsTimeStamp imageStamp;
|
||||
/* Added this delay for the thread not to hog the processor. No need to run on full speed. */
|
||||
epicsThreadSleep(0.01);
|
||||
|
||||
// get current image transfer status.
|
||||
// get image transfer status.
|
||||
imageTransferStatus(m_hdcam, captransferinfo);
|
||||
|
||||
// get image information
|
||||
int32 pixeltype = 0, width = 0, rowbytes = 0, height = 0, framebytes = 0;
|
||||
getImageInformation(m_hdcam, pixeltype, width, rowbytes, height, framebytes);
|
||||
if (prevAcquisitionCount < captransferinfo.nFrameCount) {
|
||||
//printf("nFrameCount: %d, nNewestFrameIndex: %d\n", captransferinfo.nFrameCount, captransferinfo.nNewestFrameIndex);
|
||||
prevAcquisitionCount = captransferinfo.nFrameCount;
|
||||
|
||||
if( pixeltype != DCAM_PIXELTYPE_MONO16 ) {
|
||||
printf( "not implement\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
setIntegerParam(NDArraySizeX, (int)width);
|
||||
setIntegerParam(NDArraySizeY, (int)height);
|
||||
/* Do callbacks so higher layers see any changes */
|
||||
callParamCallbacks();
|
||||
|
||||
image = new unsigned char[width * 2 * height];
|
||||
memset(image, 0, width * 2 * height);
|
||||
// get image information
|
||||
int32 pixeltype = 0, width = 0, rowbytes = 0, height = 0, framebytes = 0;
|
||||
getImageInformation(m_hdcam, pixeltype, width, rowbytes, height, framebytes);
|
||||
|
||||
count++;
|
||||
accessCapturedImage(m_hdcam, captransferinfo.nNewestFrameIndex, image, width * 2, width, height);
|
||||
|
||||
getIntegerParam(NDArrayCallbacks, &callback);
|
||||
if(callback) {
|
||||
|
||||
NDArray *pImage;
|
||||
size_t dims[2];
|
||||
int itemp=0;
|
||||
|
||||
getIntegerParam(NDArraySizeX, &itemp); dims[0] = itemp;
|
||||
getIntegerParam(NDArraySizeY, &itemp); dims[1] = itemp;
|
||||
pImage = pNDArrayPool->alloc(2, dims, NDUInt16, 0, 0);
|
||||
|
||||
if(pImage) {
|
||||
pImage->uniqueId = count;
|
||||
pImage->timeStamp = imageStamp.secPastEpoch +
|
||||
(imageStamp.nsec / 1.0e9);
|
||||
updateTimeStamp(&pImage->epicsTS);
|
||||
|
||||
memcpy(pImage->pData, (epicsUInt16 *)image, pImage->dataSize);
|
||||
|
||||
getAttributes(pImage->pAttributeList);
|
||||
doCallbacksGenericPointer(pImage, NDArrayData, 0);
|
||||
pImage->release();
|
||||
if( pixeltype != DCAM_PIXELTYPE_MONO16 ) {
|
||||
printf( "not implement\n" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setIntegerParam(NDArraySizeX, (int)width);
|
||||
setIntegerParam(NDArraySizeY, (int)height);
|
||||
/* Do callbacks so higher layers see any changes */
|
||||
callParamCallbacks();
|
||||
|
||||
image = new unsigned char[width * 2 * height];
|
||||
memset(image, 0, width * 2 * height);
|
||||
|
||||
delete[] image;
|
||||
count++;
|
||||
accessCapturedImage(m_hdcam, captransferinfo.nNewestFrameIndex, image, width * 2, width, height);
|
||||
|
||||
getIntegerParam(NDArrayCallbacks, &callback);
|
||||
if(callback) {
|
||||
|
||||
NDArray *pImage;
|
||||
size_t dims[2];
|
||||
int itemp=0;
|
||||
|
||||
getIntegerParam(NDArraySizeX, &itemp); dims[0] = itemp;
|
||||
getIntegerParam(NDArraySizeY, &itemp); dims[1] = itemp;
|
||||
pImage = pNDArrayPool->alloc(2, dims, NDUInt16, 0, 0);
|
||||
|
||||
if(pImage) {
|
||||
pImage->uniqueId = count;
|
||||
pImage->timeStamp = imageStamp.secPastEpoch +
|
||||
(imageStamp.nsec / 1.0e9);
|
||||
updateTimeStamp(&pImage->epicsTS);
|
||||
|
||||
memcpy(pImage->pData, (epicsUInt16 *)image, pImage->dataSize);
|
||||
|
||||
getAttributes(pImage->pAttributeList);
|
||||
doCallbacksGenericPointer(pImage, NDArrayData, 0);
|
||||
pImage->release();
|
||||
}
|
||||
}
|
||||
|
||||
delete[] image;
|
||||
}
|
||||
}
|
||||
}
|
||||
//============================================================================
|
||||
@@ -1009,7 +1016,7 @@ asynStatus Hama::startAcquire(void)
|
||||
// start capture
|
||||
m_err = dcamcap_start(m_hdcam, DCAMCAP_START_SEQUENCE);
|
||||
if(failed(m_err)) {
|
||||
printError( m_hdcam, m_err, "dcamcap_start()" );
|
||||
printError(m_hdcam, m_err, "dcamcap_start()");
|
||||
status = asynError;
|
||||
}
|
||||
else {
|
||||
@@ -1019,7 +1026,7 @@ asynStatus Hama::startAcquire(void)
|
||||
memset( &waitstart, 0, sizeof(waitstart) );
|
||||
waitstart.size = sizeof(waitstart);
|
||||
waitstart.eventmask = DCAMWAIT_CAPEVENT_FRAMEREADY;
|
||||
waitstart.timeout = 1000;
|
||||
waitstart.timeout = DCAMWAIT_TIMEOUT_INFINITE;
|
||||
|
||||
m_err = dcamwait_start(hwait, &waitstart);
|
||||
if(failed(m_err)) {
|
||||
@@ -1131,7 +1138,7 @@ void Hama::getImageInformation(HDCAM hdcam, int32& pixeltype, int32& width, int3
|
||||
framebytes = (int32)property_value;
|
||||
}
|
||||
|
||||
asynStatus Hama::imageTransferStatus(HDCAM hdcam, DCAMCAP_TRANSFERINFO captransferinfo)
|
||||
asynStatus Hama::imageTransferStatus(HDCAM hdcam, DCAMCAP_TRANSFERINFO &captransferinfo)
|
||||
{
|
||||
DCAMERR err;
|
||||
// transferinfo param
|
||||
|
||||
@@ -270,7 +270,7 @@ private:
|
||||
asynStatus startAcquire(void);
|
||||
void getImageInformation(HDCAM hdcam, int32& pixeltype, int32& width, int32& rowbytes, int32& height, int32& framebytes);
|
||||
asynStatus accessCapturedImage(HDCAM hdcam, int32 iFrame, void* buf, int32 rowbytes, int32 cx, int32 cy);
|
||||
asynStatus imageTransferStatus(HDCAM hdcam, DCAMCAP_TRANSFERINFO captransferinfo);
|
||||
asynStatus imageTransferStatus(HDCAM hdcam, DCAMCAP_TRANSFERINFO &captransferinfo);
|
||||
|
||||
|
||||
// wrapper functions for dcamapi
|
||||
|
||||
Reference in New Issue
Block a user