Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple example to capture a frame with an uEye Camera under Linux; compile with: gcc -Wall test_frame_capture.c -lueye_api -o frametest
#include<stdio.h>
#include<stddef.h>
#include<ueye.h>
HIDS hCam = 1;
void main() {
printf("Success-Code: %d\n",IS_SUCCESS);
//Kamera öffnen
INT nRet = is_InitCamera (&hCam, NULL);
printf("Status Init %d\n",nRet);
//Pixel-Clock setzen
UINT nPixelClockDefault = 9;
nRet = is_PixelClock(hCam, IS_PIXELCLOCK_CMD_SET,
(void*)&nPixelClockDefault,
sizeof(nPixelClockDefault));
printf("Status is_PixelClock %d\n",nRet);
//Farbmodus der Kamera setzen
//INT colorMode = IS_CM_CBYCRY_PACKED;
INT colorMode = IS_CM_BGR8_PACKED;
nRet = is_SetColorMode(hCam,colorMode);
printf("Status SetColorMode %d\n",nRet);
UINT formatID = 4;
//Bildgröße einstellen -> 2592x1944
nRet = is_ImageFormat(hCam, IMGFRMT_CMD_SET_FORMAT, &formatID, 4);
printf("Status ImageFormat %d\n",nRet);
//Speicher für Bild alloziieren
char* pMem = NULL;
int memID = 0;
nRet = is_AllocImageMem(hCam, 2592, 1944, 16, &pMem, &memID);
printf("Status AllocImage %d\n",nRet);
//diesen Speicher aktiv setzen
nRet = is_SetImageMem(hCam, pMem, memID);
printf("Status SetImageMem %d\n",nRet);
//Bilder im Kameraspeicher belassen
INT displayMode = IS_SET_DM_DIB;
nRet = is_SetDisplayMode (hCam, displayMode);
printf("Status displayMode %d\n",nRet);
//Bild aufnehmen
nRet = is_FreezeVideo(hCam, IS_WAIT);
printf("Status is_FreezeVideo %d\n",nRet);
//Bild aus dem Speicher auslesen und als Datei speichern
IMAGE_FILE_PARAMS ImageFileParams;
ImageFileParams.pwchFileName = L"./snap_BGR8.png";
ImageFileParams.pnImageID = NULL;
ImageFileParams.ppcImageMem = NULL;
ImageFileParams.nQuality = 0;
ImageFileParams.nFileType = IS_IMG_PNG;
nRet = is_ImageFile(hCam, IS_IMAGE_FILE_CMD_SAVE, (void*) &ImageFileParams, sizeof(ImageFileParams));
printf("Status is_ImageFile %d\n",nRet);
ImageFileParams.pwchFileName = L"./snap_BGR8.bmp";
ImageFileParams.pnImageID = NULL;
ImageFileParams.ppcImageMem = NULL;
ImageFileParams.nQuality = 0;
ImageFileParams.nFileType = IS_IMG_BMP;
nRet = is_ImageFile(hCam, IS_IMAGE_FILE_CMD_SAVE, (void*) &ImageFileParams, sizeof(ImageFileParams));
printf("Status is_ImageFile %d\n",nRet);
ImageFileParams.pwchFileName = L"./snap_BGR8.jpg";
ImageFileParams.pnImageID = NULL;
ImageFileParams.ppcImageMem = NULL;
ImageFileParams.nQuality = 0;
ImageFileParams.nFileType = IS_IMG_JPG;
nRet = is_ImageFile(hCam, IS_IMAGE_FILE_CMD_SAVE, (void*) &ImageFileParams, sizeof(ImageFileParams));
printf("Status is_ImageFile %d\n",nRet);
//Kamera wieder freigeben
is_ExitCamera(hCam);
}
@alejandronespereira
Copy link

alejandronespereira commented Jan 27, 2017

Thanks man! I have been battling with this for a while and finding this gist was a great discovery, worked like a charm!

@ChristianUlbrich
Copy link
Author

ChristianUlbrich commented Mar 2, 2017

@alejandronespereira You are welcome. Note to myself: I shall not publish gists with German comments. Although I guess you might have figured the meanings out already. :) I wonder, that this 3 year old (those were the times...) code still works, looks like IDS kept their API stable (hard to come by these days...).

@jeremy-rutman
Copy link

jeremy-rutman commented Apr 12, 2017

Hi ,
We are using the MT9P031M monochrome sensor and it looks like we need to not do the debayering as our results have psychedelic colors instead of grayscale - we tried setting

INT colorMode = IS_COLORMODE_MONOCHROME ;
also IS_CM_SENSOR_RAW8, IS_CM_MONO8 gave similar results,
while IS_CM_SENSOR_RAW10, RAW12 gave error 174 (invalid color format)

Also tried

nMode=0;  //or 1 
nRet=is_SetBayerConversion(hCam,nMode);

is there some way to tell what value this is supposed to be to not do bayer conversion? (the mono camera wont have the filter so I guess what is happening is that unwanted debayering is making the result colors look wierd instead of grayscale)

@Maninderdeosi
Copy link

Maninderdeosi commented Oct 27, 2017

how could i link ueye.h file to the codeblock?
please help.

@Yoeky
Copy link

Yoeky commented Nov 14, 2018

Hi, does somebody have a simple example like this for using the freerun mode with is_CaptureVideo() on plain linux ?
I can grab images, change all settings/gain/AOI etc. but struggle using is_AddToSequence and is_CaptureVideo instead of is_FreezeVideo.

What I eventually want to do is, set a small AOI to achieve a high fps (>150) and then send triggers via udp once some special marked (red color) object comes into the camera area. This should be a simple linux console program. I'm stuck with the change from is_FreezeVideo to is_CaptureVideo to achieve the higher fps...

@aminsut
Copy link

aminsut commented Oct 11, 2020

hello and thanks for your code.
I have a problem with loading the uEye.h on qt creator.
My error that I encountered is uEye.h: No such file or directory.
Can you help me solve this issue? (like how to install this library and ...)
thanks and best regards.

@islandmonkey
Copy link

islandmonkey commented Jan 22, 2021

Hi, does somebody have a simple example like this for using the freerun mode with is_CaptureVideo() on plain linux ?
I can grab images, change all settings/gain/AOI etc. but struggle using is_AddToSequence and is_CaptureVideo instead of is_FreezeVideo.

What I eventually want to do is, set a small AOI to achieve a high fps (>150) and then send triggers via udp once some special marked (red color) object comes into the camera area. This should be a simple linux console program. I'm stuck with the change from is_FreezeVideo to is_CaptureVideo to achieve the higher fps...

@Yoeky have you ever succeded using addtosequence with capturevideo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment