Hi all,
I’m using Dalsa Nano C2420 with third generation acqusition interface.
When I use the Dalsa with GenICam Browser, I can snap and save color 24 pictures that I’m looking for, but when I use it into my c++ code, I only have monochrome pictures.
Can somebody help me ? ^^
There is my code :
m_cvbDevice = new_device;
if (m_cvbDevice == nullptr || !m_cvbDevice)
throw std::exception("cannot acces device, my_genICame_device_ptr is nullptr");
if (m_cvbDevice->ConnectionState() == Cvb::ConnectionState::NotSupported)
throw std::exception("device not supported");
if (m_cvbDevice->ConnectionState() != Cvb::ConnectionState::Connected)
throw std::exception("device not connected");
m_imageStream = m_cvbDevice->Stream<Cvb::CompositeStream>();
if (m_imageStream == nullptr)
return new CImageNew();
Cvb::CompositePtr composite;
Cvb::WaitStatus status;
Cvb::NodeMapEnumerator nodeMaps;
m_imageStream->Start();
std::tie(composite, status, nodeMaps) = m_imageStream->Wait();
m_imageStream->Abort();
auto multiImagePart = Cvb::MultiPartImage::FromComposite(composite);
int count = multiImagePart->PlanesCount();
auto part = multiImagePart->GetPartAt(0);
if (!Cvb::holds_alternative<Cvb::ImagePtr>(part))
;//TODO manage error
else
{
auto image = Cvb::get<Cvb::ImagePtr>(part);
image->Save(L"P:\\Library\\test\\cvb_image_from_multipart.bmp");
auto plane = image->Plane(0);
auto dataType = plane.DataType();
auto linearAccess = image->Plane(0).LinearAccess();
auto buffer = linearAccess.BasePtr();
{
size_t bufferIndex = 0;
CImageColor24 image(imagePtr->Width(), imagePtr->Height());
for (size_t index = 0; index < imagePtr->PlanesCount(); index++) {
unsigned char* plane = imagePtr->Plane(index).LinearAccess().BasePtr();
size_t imagePixelCount = imagePtr->Width() * imagePtr->Height();
for (size_t ii = 0; ii < imagePixelCount; ii++) {
image[bufferIndex][0] = plane[ii];
image[bufferIndex][1] = plane[ii];
image[bufferIndex][2] = plane[ii];
bufferIndex++;
}
}
}
}