Save Image to disk use detectNet-camera

I want to save face image as dataset to train a face classify model use detectNet-camera.
I just want to save face area not the whole image.
I try to add code to save the image in Jetson-inference detectNet-camera like below.
Save image in “if( !net->DrawBoxes((float*)imgRGBA, (float*)imgRGBA, camera->GetWidth(), camera->GetHeight(),
bbCUDA + (lastStart * 4), (n - lastStart) + 1, lastClass) )”

int imgW = bb[2] - bb[0];
  int imgH = bb[3] - bb[1];
 saveImageRGBA(filename, (float4*)imgCPU,imgW , imgH ,255.0f );

But the app crash and just save one broken image when start.

By the way, I can’t log in this forum use Safari.
How to search topic in this forum?

Hi zip520123, the imgCPU pointer is YUV colorspace - to use saveImageRGBA() function, you are looking for imgRGBA pointer. Also you must change detectnet-camera.cpp:184 to the following:

// -if( !camera->ConvertRGBA(imgCUDA, &imgRGBA) )
if( !camera->ConvertRGBA(imgCUDA, &imgRGBA, true) )

The 3rd boolean parameter ‘true’ to ConvertRGBA() lets the function know you want to use the RGBA image on the CPU (default is CUDA-only).

Thank you for your advice, dusty_nv.
Save image work now. ^_^
I’m new to Jetson-inference.
I want to crop face area not whole image.
I find there are some function description in doc/index.html, but I still have no idea to crop Image.
How to crop imgRGBA?

1 Like

Hi,

You can implement crop function by modifying data index here:
https://github.com/dusty-nv/jetson-inference/blob/master/imageNet.cu#L75

Thanks.

Hello @zip520123 @AastaLLL @dusty_nv
I am trying to do the same thing. but I am still a beginner. would you mind to gave me some guide or advice to do that.

and thanks .