I ran into the problem of passing an Image object (captured using the Point Grej FlyCapture2 SDK) to a QImage object. I get a pointer associated with image data by function:
virtual unsigned char* FlyCapture2::GetData ( )
and then upload the data:
QImage::QImage ( uchar * data, int width, int height, int bytesPerLine, Format format )
The data formats of both Image objects are 8-bit monocolors. The BytesPerLine parameter should be equal to the width of the image (I already checked it by saving FlyCapture2 :: Image to .bmp and then loading it into QImage).
Is there a problem that you are throwing from unsigned char * to uchar *? Do you have any other ideas? Copying pixel by pixel pixels is too slow.
EDIT: I am converting an image captured by FlyCapture to FlyCapture2::PIXEL_FORMAT_RGB8 for which: R = G = B = 8 bits, inside the PGR::SnapShot() function. SnapShot () returns an unsigned char * const. and here is part of my Qt mapping function:
unsigned char *const img = PGRSystem->SnapShot(); QImage Img(img, 1024, 768, QImage::Format_RGB888); QGraphicsScene *Scene = new QGraphicsScene(); Scene->addPixmap(QPixmap::fromImage(Img)); ui.ImageView->setScene(Scene); ui.ImageView->fitInView(ui.ImageView->itemAt(100,100)); delete [] Scene;
I also tried saving Img to a file, but got an unhandled exception. I tried other pairs of pixel pixels ( FlyCapture2::PIXEL_FORMAT_RGB - 24 bit RGB with QImage::RGB88 8 and FlyCapture2::PIXEL_FORMAT_RGBU32 with QImage::RGB32 )
It is also worth mentioning that the QImage constuctor that I use does not set colorTable (I get an exception by checking if QImage is in grayScale). I need a little more help, I think.
source share