Skip to content

Instantly share code, notes, and snippets.

@ChristianUlbrich
Created December 9, 2013 12:54
Show Gist options
  • Save ChristianUlbrich/7871863 to your computer and use it in GitHub Desktop.
Save ChristianUlbrich/7871863 to your computer and use it in GitHub Desktop.
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);
}
@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

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?

@Martyn575
Copy link

Martyn575 commented Sep 22, 2022

Segfaults for on line 61. Return code from is_FreezeVideo() is 127. Looks like it can't allocate the memory.

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