Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Tom_D_1
Beginner
32 Views

RSSDK vs Openframeworks: ReleaseAccess causes crash

Hello Forum,

I'm working on a 3D-scanner in openframeworks. I recently updated to R2 of the SDK, and my R1-based project wasnt working anymore. For some reason i have an read-access violation when i release access to my ImageData. When i do not release it, well, you have a memory-hungry application.

 

This is the part of the update where everyting is going south;

PXCImage *previewImage = scanModule->AcquirePreviewImage();

		if (previewImage && uPreview) {

			PXCImage::ImageData previewData;
			PXCImage::ImageInfo previewInfo = previewImage->QueryInfo();

			if (logImageTypes) ofLogNotice("senseManger previewImage: " + ofToString(previewInfo.width) + ", " + ofToString(previewInfo.height) + " in: " + convertWString(PXCImage::PixelFormatToString(previewInfo.format)));

			if (!previewPixels.isAllocated()) previewPixels.allocate(previewInfo.width, previewInfo.height,ofPixelFormat::OF_PIXELS_BGR);
			if (previewPixels.getWidth() != previewInfo.width) previewPixels.resize(previewInfo.width, previewInfo.height);

			pxcStatus accessStatus = previewImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB24, &previewData);
			
			if (accessStatus == PXC_STATUS_NO_ERROR) {
				
				previewPixels.setFromExternalPixels(reinterpret_cast<uint8_t*>(previewData.planes[0]), previewInfo.width, previewInfo.height, ofPixelFormat::OF_PIXELS_BGR);
				
				
				previewImage->ReleaseAccess(&previewData);
				previewImage->Release();
			}
			else {

				//everything is terrible.

			}

 

I can imagine that setFromExternalPixels isnt done yet and causes the error, however im using that for the color and depth stream as well. Not giving any problems. Is there any other way that using acquireAccess and releaseAccess?

 

Tom

0 Kudos
1 Reply
Tom_D_1
Beginner
32 Views

Solved. Either publish or dont. I found this a bit voodoo-ish method.

previewImage is released at the start of the new frame aqcuire. 

if(previewImage != nullptr){

  previewImage->Release();
  previewImage = NULL;

} // rest of frameaqcuire

The access to previewImage is released earlier, in the frameRelease function.

Reply