Skip to content

Commit

Permalink
Resolve bug w/ colored images not reporting shape correctly, also fix…
Browse files Browse the repository at this point in the history
… fairly serious compiler warning
  • Loading branch information
jwlodek committed Aug 15, 2024
1 parent 88a7d66 commit 0bf6c58
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions uvcApp/src/ADUVC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,6 @@ asynStatus ADUVC::uvc2NDArray(uvc_frame_t* frame, NDArray* pArray,
*/
void ADUVC::newFrameCallback(uvc_frame_t* frame, void* ptr){
NDArray* pArray;
NDArrayInfo arrayInfo;
int dataType;
int operatingMode;
int colorMode;
Expand Down Expand Up @@ -962,19 +961,31 @@ void ADUVC::newFrameCallback(uvc_frame_t* frame, void* ptr){
pArray = this->pArrays[0];
}
else{
this->pArrays[0]->release();
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s Unable to allocate array\n", driverName, functionName);
return;
}

updateTimeStamp(&pArray->epicsTS);

int pixelSize = 1;
switch(dataType){
case NDUInt8:
case NDInt8:
pixelSize = 1;
break;
case NDUInt16:
case NDInt16:
pixelSize = 2;
break;
}

// Update camera image parameters
pArray->getInfo(&arrayInfo);
setIntegerParam(NDArraySize, (int)arrayInfo.totalBytes);
setIntegerParam(NDArraySizeX, arrayInfo.xSize);
setIntegerParam(NDArraySizeY, arrayInfo.ySize);
size_t dataSize = dims[0] * dims[1] * pixelSize;
if (ndims == 3) dataSize *= dims[2];
setIntegerParam(NDArraySize, (int)dataSize);
setIntegerParam(NDArraySizeX, frame->width);
setIntegerParam(NDArraySizeY, frame->height);

int numImages;
getIntegerParam(ADNumImagesCounter, &numImages);
Expand All @@ -983,7 +994,7 @@ void ADUVC::newFrameCallback(uvc_frame_t* frame, void* ptr){
pArray->uniqueId = numImages;

// Copy data from our uvc frame into our NDArray
uvc2NDArray(frame, pArray, (NDDataType_t) dataType, (NDColorMode_t) colorMode, arrayInfo.totalBytes);
uvc2NDArray(frame, pArray, (NDDataType_t) dataType, (NDColorMode_t) colorMode, dataSize);

//single shot mode stops after one images
if(operatingMode == ADImageSingle){
Expand Down

0 comments on commit 0bf6c58

Please sign in to comment.