c++ image from camera

Hi, I doing a university project which involves programming a camera to take images. The camera manufacturer provides a SDK which has functions to take the images. As it says in the documentation, an object of a class provided by the SDK is created. This object is an emty container, and when the camera takes an image, this container is filled with image information (width, height etc) and the image data itself. The camera itself has no internal memory, only a 32 mb buffer (which stores a maximum of one image). The acquired images are transferred over the ethernet cable to the PC. The question is, how do I extract the data from the object I talked about earlier and save it to a bitmap file? Initially I thought that the function to take the image transfers the file to PC and saves it as a bitmap in some folder. However, I couldn't find the image anywhere, so I assumed that some function needs to be used for this. The image transfer between the camera and PC does occur (I am quite sure about it), the small LED light on the camera indicates this. But I don't understand how to save it in some folder as a bitmap.
I am very new to programming so please tell me if I am missing something here,
Last edited on
closed account (N85iE3v7)
What kind of object does the camera SDK create ? It can be a dynamic array, a customized array class, a large buffer, an STL container.
Thanks for the reply, I am not sure about this one but here is what it says in the documentation:
"Objects of BGAPI::Image are empty containers for content, that are provided by the entry
point function BGAPI::createImage. These containers can be filled with image information
such as width, height and pixel format, and image data provided by a BGAPI::Camera
object. BGAPI::Image objects can be created and released. Thereby the respective release()
command eliminates the BGAPI::Image instance. The BGAPI::Image class supports
image transformation."
closed account (N85iE3v7)
It seems you have a whole namespace to explore. It looks like you have to deal with the classes that are available and it seems that Image class might have some way to save the image to bmp.
Try to have a look at the manual and which methods you have available. It seems that your Image class encapsulates all the hard part, which would be using the windows api or directly processing the bmp file.
Link to SDK? It makes sense that it would just be a member function of the Image object, although I doubt they would use bmp, as it's horrible for compression, my bet would be on png or jpg.
closed account (N85iE3v7)
I haven't had the time to read it or download, sorry about that:
ftp.elvitec.fr/Baumer/MANUELS/ProgrammersGuide_v50e_0100401.pdf
The OP mentions a bitmap, usually that sort of picture was not processed in terms of compression, and what you see is a collection of pixels, while a jpg is a result of a mathematical transformation. though these days, you can have real great quality jpgs.
Sorry for slow reply, but here is where I got with this:
Initially I was hoping that it would indeed be a member function of the image object, but unfortunately it's not the case. I didn't mention this, but a similar project with the same camera has been done a year ago in the same language and the guy did manage to save pictures in bmp format. Unfortunately i have no way of contacting the person.

zlogdan, unfortunately the link is not working at the moment but i also have a file called Programmers Guide which was provided with the Baumer TXG 50c camera and I did read it of course. No mentioning of bitmaps there..

Anyway, I tried reading the previous guy's code, and there was a Createbitmap method in it and SaveImage method as well. After adjusting the code a bit this is what I got (the code only applies when captured images are in BGR8 Packed format, also i do understand that some of the lines in the code are not needed and can be removed):

void CreateAndSaveBitmap(BGAPI::Image* image, Bitmap^ bmp)
{int bgapierror = 0;

int* w = 0;
int* h = 0;
int* len = 0;
int* pixelformat = 0;
int stride = 0;

System::Drawing::Imaging::PixelFormat format = System::Drawing::Imaging::PixelFormat::Undefined;


image->getPixelFormat(pixelformat);
image->getSize(w, h);
image->getImageLength(len);

format = System::Drawing::Imaging::PixelFormat::Format24bppRgb;
image->setDestinationPixelFormat(BGAPI_PIXTYPE_BGR8_PACKED);
image->getTransformBufferLength(len);
Rectangle^ rect = gcnew Rectangle(0, 0, *w, *h);
System::Drawing::Imaging::BitmapData^ bmpData =bmp->LockBits(*rect, System::Drawing::Imaging::ImageLockMode::ReadWrite,bmp->PixelFormat);
bgapierror = image->doTransform(reinterpret_cast<unsigned char*>(bmpData->Scan0.ToPointer()), *len);

// Unlock the bits.
bmp->UnlockBits(bmpData);

//reset transformation settings
image->resetTransformSettings();

if (bgapierror != BGAPI_RESULT_OK)
printf("error");
bmp->Save("1", System::Drawing::Imaging::ImageFormat::Bmp);

Can you guys tell me whether this could really be creating and saving the bitmap? I can provide explanations of functions from the SDK later if needed.
I tested this code yesterday in debug mode in Visual Studio and I got an error something like "Attempted to write protected memory, other memory could be corrupted".
Also I contacted the manufacturer with the same question, no answer yet.
Last edited on
Also later I will upload the help file which exlains all the classes and members from the SDK if you guys have time to look at it (not expecting you of course)
Here is the link for the help file which gives explanation on all the members of the classes provided:
https://rapidshare.com/files/457731836/bgapihelp.chm
Topic archived. No new replies allowed.