Comments (5)
Hello
I am sorry for my late answer.
From my understanding, you do not unpack the 12bit format correctly, but you simply uses 2 bytes per pixel. I suggest to use
"Polarized Mono 8" first and separate the incoming images with
void CreatePolarImages(int width, int height, _MyData *pData)
{
if (!pData->mat_created)
{
int h = height / 2;
int w = width / 2;
for (int i = 0; i < 4; i++)
{
pData->grayImage[i].create( h, w, CV_8UC1);
pData->colorImage[i].create(h , w, CV_8UC4);
char WindowName[256];
sprintf(WindowName, "Polarization %d", i + 1);
cv::namedWindow(WindowName);
}
pData->mat_created = true;
}
}
/////////////////////////////////////////////////////////////////////////
//
void AcquisitionCallback(ArvStream *pStream, void *pVoidData)
{
_MyData *pMyData = (_MyData *)pVoidData;
ArvBuffer *pBuffer = arv_stream_try_pop_buffer(pStream);
if (pBuffer != NULL)
{
ArvBufferStatus Status = arv_buffer_get_status(pBuffer);
if (Status == ARV_BUFFER_STATUS_SUCCESS)
{
pMyData->ImageReceived = true;
int height = arv_buffer_get_image_height( pBuffer);
int width = arv_buffer_get_image_width( pBuffer);
pMyData->displayImage.create( height, width,
ArvPixelFormat2OpenCVType( pBuffer )
);
size_t buffersize;
const void* bytes = arv_buffer_get_data(pBuffer, &buffersize);
memcpy( pMyData->displayImage.data, bytes, buffersize );
if( strcmp(pMyData->displayWindowName,"") != 0)
{
cv::imshow(pMyData->displayWindowName, pMyData->displayImage);
cv::waitKey(1);
}
CreatePolarImages(width,height, pMyData);
unsigned char* sourcePixel = (unsigned char*)bytes;
unsigned char* destPixel[4];
for (int i = 0; i < 4; i++)
{
destPixel[i] = pMyData->grayImage[i].data;
}
for (int y = 0; y < height; y += 2)
{
for (int x = 0; x < width; x += 2)
{
*destPixel[1]++ = *sourcePixel++;
*destPixel[0]++ = *sourcePixel++;
}
for (int x = 0; x < width; x += 2)
{
*destPixel[2]++ = *sourcePixel++;
*destPixel[3]++ = *sourcePixel++;
}
}
for (int i = 0; i < 4; i++)
{
cv::cvtColor(pMyData->grayImage[i], pMyData->colorImage[i], cv::COLOR_BayerRG2BGR);
}
ShowPolarImages(pMyData);
arv_stream_push_buffer(pStream, pBuffer);
}
else
{
if( Status == ARV_BUFFER_STATUS_TIMEOUT)
{
pMyData->Packettimeouts++;
//printf("Paket timeouts %d\n", pMyData->Packettimeouts);
}
else
{
printf("%s\n",getErrormessage(Status).c_str());
}
arv_stream_push_buffer(pStream, pBuffer);
pMyData->error = true;
}
}
else
{
printf("Buffer is null\n");
}
}
If this works, you may change to 16 bits using the "Polarized Mono 16" format.
Stefan
from tiscamera.
Hi Stefan,
Thank you for your answer.
- More than half of the code in your example is missing. I was lucky to find the code zipped in an other issue.
- When compile with aravis-0.8 and OpenCV 4.6, the executable stay idle, and do nothing.
That said I was able to test, and adapt your code to work with PolarizedMono8
and PolarizedMono16
.
Nonetheless I still want to use to PolarizedMono12Packed
, what should I do to retrieve the information?
Thanks in advance.
Sincerely,
Julien Fleuret
from tiscamera.
Hello
I saw you also asked my US colleagues, who asked me too. However, I added the sample for Mono 8 at https://github.com/TheImagingSource/Linux-tiscamera-Programming-Samples/tree/master/cpp/Extract-four-images-from-polarization-camera. There should nothing missing.
12bit packed means, that 12bits make a pixel. Then immediately the next 12bits follow in the second byte of the first pixel. So you need to extract this stream.
You have 3 bytes for two pixels and split them accordingly. The idea could be:
p1 = (WORD)*data & 0xFFF0;
p1 = p1 >> 4;
pdata++;
p2 = (WORD)*data & 0x0FFF;
data is a BYTE* pointer to the image data.
But I did not try that on my own. If that does not work as expected, please let me know.
Best regards
Stefan
from tiscamera.
Hello Julien
I updated the above mentioned sample. It handles the mono 12bit packed and mono 16 bit video formats now. Unpacking of 12bits to 16bits is not that easy as I thought.
Stefan
from tiscamera.
Hi Stefan,
Thank you very much.
It helps a lot.
Sincerely,
Julien
from tiscamera.
Related Issues (20)
- ERROR tcam-libtcam timeout while waiting for new image buffer HOT 5
- Broken dependency HOT 4
- Failed to find any device to open DMK23G445 HOT 2
- Feature Requset: Callback for external trigger, before sensor read-off HOT 6
- Cmake cannot find tcam HOT 1
- Is there a DFK31BU camera driver available for the Raspberry Pi? HOT 7
- Intermittent failure to change pipeline state HOT 9
- Unable to use v4l2-ctl to update gain HOT 2
- Rasberry Pi 3 Arducam Day-Night Vision Camera not available HOT 1
- unable to detect camera on ubuntu HOT 5
- AttributeError: 'GstTcamBin' object has no attribute 'get_device_serials_backend' while running the 00-list-devices.py HOT 6
- support 23.04, 23.10, and 24.04 HOT 3
- Performance Variation Across Ubuntu Versions and tiscamera Package Versions HOT 4
- Is it Possible to Share a GigE Camera Feed Between Two PCs? HOT 2
- Use dfk 33ux287 tisCam code to install library fail HOT 7
- Stuck setting pipeline state to ready - pipeline.set_state(Gst.State.READY) due to TriggerMode HOT 3
- Cannot verify installation in Jetson AGX Orin HOT 8
- No v4l2 firmware support for DFK 61BUC02 Cameras HOT 1
- A solution for DMK 21BUC03? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tiscamera.