Can not save BayerRG8 images in colors.
AnsweredWe use SpinnakerSDK V4.0.0.0.116_x64 (SpinnakerSDK_FULL_4.0.0.116_x64.exe).
We use BFS-PGE-04S2C camera module.
Camera module is configured to use "BayerRG8" pixels format.
When saving image using "Spinview", resulting image is monochrome whatever
the image type selected.
When saving image using "SpinnakerSDK" API, resulting image is monochrome.
We tried without converting image and we try using the following conversions:
PixelFormat_RGB8, PixelFormat_BGR8.
See following code section for details.
/* Code section begin. */
Spinnaker::ImagePtr ImagePtrTmp;
Spinnaker::TIFFOption option;
ofstream ofs_ts;
// Create ImageProcessor instance for post processing images
//
Spinnaker::ImageProcessor processor;
// Set default image processor color processing method
//
processor.SetColorProcessing(Spinnaker::SPINNAKER_COLOR_PROCESSING_ALGORITHM_HQ_LINEAR);
option.compression = Spinnaker::SPINNAKER_TIFF_COMPRESS_METHOD_NONE;
strcpy(string, fn_ba_move_n);
strcat(string, ".txt");
ofs_ts.open(string);
file_idx = 1;
/* Write header to image time stamp file.
* -------------------------------------- */
ofs_ts << "#" << "\t" << "Time Stamp" << endl;
ofs_ts << "-" << "\t" << "----------" << endl;
/* Save revealing images stored in the buffer.
* ------------------------------------------- */
while (TRUE)
{
ostringstream filename;
ImagePtrTmp =
Spinnaker::Image::Create(
TOPCAM_BA_ROI_WIDTH, TOPCAM_BA_ROI_HEIGHT, 0, 0,
Spinnaker::PixelFormatEnums::PixelFormat_BayerRG8,
img_data1[iii]);
// processor.Convert(ImagePtrTmp, Spinnaker::PixelFormat_RGB8);
processor.Convert(ImagePtrTmp, Spinnaker::PixelFormat_BGR8);
strcpy(string, fn_ba_move_n);
strcat(string, "-");
filename << string << file_idx << ".tif";
/* Save image.
* */
ImagePtrTmp->Save(filename.str().c_str(), option);
/* Code section end. */
Any clue about why images are not saved with colours ?
-
Official comment
Hello Ifeanyi,
Thank you for your information concerning saving color image from SpinView preview window.
We can save color images using Spinview, now :-)
Thank you for your advice concerning saving color image using the Spinnaker SDK API.
Looking at "Acquisition" example, we found that our problem was due to using wrong image pointer when saving the image.Before correction (wrong code):
+++
processor.Convert(ImagePtrTmp, Spinnaker::PixelFormat_RGB8);
ImagePtrTmp->Save(filename.str().c_str(), option);
+++After correction (good code):
+++
Spinnaker::ImagePtr convertedImage = processor.Convert(ImagePtrTmp, Spinnaker::PixelFormat_BGR8);
convertedImage->Save(filename.str().c_str(), option);
+++
Regards,Claude
-
Hello Claude,
It is not clear the content of image data, "img_data1" and how it was loaded. There are some questions to help understand and resolve this issue:
- To separate "img_data1" from rest of the code, does it work fine if you capture image directly from camera (with BayerRG8 pixel format) using the same code?
- How did you determine output is not 3-channel colour image?
- Is result the same using different image format such as jpg or png?
Thanks,
Regards,
Ifeanyi.
0 -
Hello Ifeanyi,
>
> It is not clear the content of image data, "img_data1" and how it was loaded. There are some questions to help understand and resolve this issue:
>"img_data1" is a circular buffer containing many images acquired by the BFS-PGE-04S2C camera module.
It is defined as:
+++
/* Images Data secondary circular buffer pointer.
* */
uint8_t **img_data1 = NULL;
+++This buffer is filled using:
Spinnaker::ImagePtr pImage->GetData();
>
> - To separate "img_data1" from rest of the code, does it work fine if you capture image directly from camera (with BayerRG8 pixel format) using the same code?
>I think there is no need to make the test you mentioned, since this code come from a program that we use (with success) since many years on another device based on BFS-U3-16S2M-CS camera module.
>
> - How did you determine output is not 3-channel colour image?
>We display saved image using:
- Windows 10 Explorer preview (Extra large icons)
- "IrfanView"
- GIMPRemarks: When looking at saved (monochrome) images, we can see the pattern of Bayer encoding. It looks like a checkerboard.
See attached images:
- First image (printscreen_spinview_2024-02-28_1141.jpg)
Print Screen showing what is seen in "Spinnaker" Preview.- Second image (spinview_saved_img_2024-02-28_1138.jpg)
Image saved using "SpinView" "Save current image to disk" button.>
> - Is result the same using different image format such as jpg or png?
>Yes. We have done the test the following way:
1) Configure the BFS-PGE-04S2C camera module using our program.
2) Then, use "SpinView" (without modifying configuration done at
step 1) to save/view images, using all format available in
"SpinView".
Regards,Claude
0 -
Hello Claude,
To save image as rendered would require to ensure that "Save Displayed Image" is selected from SpinView drawing window (i.e right-click in drawing window --> Save Image Options --> Save Displayed Image):
For code implementation, do you observe the same issue if you run our Acquisition.cpp example code? I would edit the code at line 368 to use color pixel format, PixelFormat_RGB8.
If this example code works fine, I would compare it with custom code implementation. Otherwise, please open support ticket by using our contact form at https://flir.custhelp.com/app/ask, and we could have a remote session to work through this together.
Regards,
Ifeanyi
0 -
Hi Claude,
Thanks for the update, and glad to know that this is resolved.
Regards,
Ifeanyi
0
Please sign in to leave a comment.
Comments
5 comments