-2

I am using ubuntu and I have AVT GigEvision camera. The SDK for linux environment for this camera can be downloaded from [Link for Linux_SDK libraries] http://www.alliedvisiontec.com/us/products/legacy.html. I am able to acquire the images at 1 Frame per second as It is some default value but How do I start receiving more frames per second. I am not sure whether it outputs bayerrg8 format or mono 8 format, at the moment I can see a black and white picture. I am not sure whether the data from camera was bayer8 and the drivers automatically converted it to mono8 or the data from the camera is mono8 and I need to convert it to bayer8. Also if yes I am not able to find any specific function to convert from mono8 to bayerrg8.

user3217310
  • 144
  • 1
  • 17

1 Answers1

1

Setting Frame Rate

To change frame rate on GigE Vision camera you need to set parameter named AcquisitionFrameRate. This is standard parameter and has to be supported by all GigE Vision cameras. In terms of AVS SDK you do it like this:

err = PvAttrFloat32Set(handle, "AcquisitionFrameRate", 30.0);

Make sure you check camera's supported frame rates with PvAttrRangeFloat32().

Setting Pixel Format

The enumeration feature named PixelFormat is used to control camera's output pixel format. There's 4 different 8-bit Bayer formats: BayerBG8, BayerGB8, BayerGR8 and BayerRG8. Your camera might support just one of them or none at all. Use PvAttrRangeEnum(handle, "PixelFormat", ...) to get the list of supported pixel formats. You can then set it with:

err = PvAttrEnumSet(handle, "PixelFormat", "BayerBG8");

It's unlikely that camera streams pixels in one format and later convert it into another, because this would violate GigE Vision standard. Most probably you have pixel format set to Mono8 by default.

Getting Around with GigE Vision Camera

In order to understand what kind other parameters names you can set and how they would work you need to read the documentation for your camera, if you have any. Otherwise you can learn it from the camera itself, using PvAttrList() call to get the list of supported features and later using GenICam Standard Features Naming Convention document describing how particular feature is expected to behave.

dkz
  • 921
  • 6
  • 10
  • Thanks a lot. I am displaying image using Qt application. which can display these formats [Format_Mono,Format_MonoLSB,Format_Indexed8,Format_RGB32,Format_ARGB32,Format_ARGB32_Premultiplied,Format_RGB16,Format_ARGB8565_Premultiplied,Format_RGB666,Format_ARGB6666_Premultiplied,Format_RGB555,Format_ARGB8555_Premultiplied,Format_RGB888,Format_RGB444,Format_ARGB4444_Premultiplied] and my camera can output mono8,mono16,bayer8,baer16,rgb24,brg24,Yuv411,Yuv422,Yuv444,Rgba32,Bgra32,Rgb48,mono12packed. So I can not find any compatible format pair. I tried rgb24 frm camera n rgb888 4 display,isnt workin. – user3217310 Mar 28 '14 at 00:49
  • Also I can increase the frame rate by just setting it, but how to handle it cause if I only increase it some frame start getting dropped and I start getting error 16 (that is timeout error, I am using a imageviewer.h sample library). and does setting the frame rate 30 means that at camera.frames.imagebuffer will be changing at 30 times a second ? – user3217310 Mar 28 '14 at 01:00
  • I get a black screen if I am trying, camera out Rgb24 and qtdisplay Rgb888. Also when I try to set camera out Brga32 or these 4 byte length I get error of out of memory. – user3217310 Mar 28 '14 at 05:08
  • QT image format RGB888 sounds like compatible with rgb24, also QT's ARGB32 matches GEV's rgba32. So these cases need to be debugged. But getting RGB image out of camera is not the best option when you want to use high frame rate. Depending on your frame size RGB frames at 30 fps can easily go beyond of 1GB/s channel. Better option would be using Bayer format and converting it to RGB on client site using e.g. OpenCV `cvtColor()`. And 30 frames per second frame rate means your internal camera.frames.imagebuffer will be updated 30 times per second. – dkz Mar 28 '14 at 17:01
  • Thanks, I can not use ARGB32 formats as in that case it throws an ot of memory error. Okay so now I will take only bayer8 data from camera and convert it in rgb using Qt side. any ways I actually setted the frame rate to 30 using the PvAttrFloat32Set function. but when I run it shows frames are missed. do I need to change more setting about camera like aquisitionmode to single frame or continuous for increased frame rate or any pckt size? here is my file in which I am setting stuffs. https://dl.dropboxusercontent.com/u/13787230/imageviewer.h please check it and some suggestion about frmrate? – user3217310 Mar 28 '14 at 17:29
  • In your case frames are missed because they don't fit 1GB/s bandwidth. 1360x1024 RGB frame at 30 fps generates 1.25GB/s. You need to either lower down frame rate or switch to Bayer (or YUV) pixel format and restore it back to RGB after receiving. I also noticed your `AcquisitionMode` is set to `SingleFrame` instead of `Continious`, but I guess its for debug purposes. Also I can't tell how effective is QT's `QImage` -> `QPixMap` -> `QLabel.show()` chain to display frames at 30 fps speed, you need to research this question separately. – dkz Mar 28 '14 at 18:05
  • Thanks a lot. two things which are little unclear to me are 1. to set the frame to 30fps I just need to set the frame rate to 30 using the PvAttrFloat32Set? will it update my camera.frames.imagebuffer at 30 frames per second ? actually I have to read this camera.frames.imagebuffer somewhere else so my aim is just that it gets updates at 30fps 2. at the moment I am trying with only 1 fps but I guess I am not able to correctly convert the received bayer8 format using Qt function converttoformat to rgb888 or any coloured format but I am trying that. – user3217310 Mar 28 '14 at 18:37
  • 1. Yes, once you set `AcquisitionFrameRate` to 30 and `AcquisitionMode` to `Continious`, you should receive frames 30 times per second. You'd need not just read `camera.frames.imagebuffer` but, of cause you need to queue frames first and wait for them with `PvCaptureWaitForFrameDone()`. 2. I'm afraid QT will not help you in Bayer-to-RGB conversion. You need to use external libraries for that, like OpenCV with `cvtColor(..., CV_BayerRG2RGB)`. Otherwise you might be luckier with YUV422 conversion in QT, although it is not as optimal as Bayer. – dkz Mar 28 '14 at 19:30
  • But I will have to use QT convertformat as you can see in the header file I included in previous comments that I am using Qtfunctions in my imageviewer.h not in main.cpp, so its difficult to use opencv library in the header file. – user3217310 Mar 29 '14 at 02:01
  • It is difficult to program in C++ using just header files, and I don't think you have to. In fact I was wrong about YUV format in QT: it won't be able to show or convert anything but mono or RGB format variation. So you have to consider using something beyond QT and AVT libraries in your project. – dkz Mar 29 '14 at 07:26
  • Okay, Now I am just not trying to make it coloured any more only I wish to increase the frame rate. In the header file which I attached previously there is a function by which I am setting the frame rate (394 line) and there is one Framescount (line 27) which is setted to 1. Now If I wish to increase the frame rate to 30 then do I only need to change the value of frmrate in this function to 30 like PvAttrFloat32Set(GCamera.Handle,"FrameRate",30)? or I need to change something more in my file. Is the queueing thing happening my my header file, if not then in which place I should write function – user3217310 Mar 30 '14 at 04:17
  • Also I am able to increase the framerate upto 4-5 by the changing the value in that function only but when I increase my frame rate to 10,15,30 I see lots of frames are missed, frame completed 0, and on screen I am seeing some portion black and only some grey distorted lines not i.e not getting any thing on screen. – user3217310 Mar 30 '14 at 04:21
  • You have to do a number of changes in order to get a higher frame rate. 1) `AcquisitionFrameRate = 30.0`; 2) use `AcquisitionMode = Continuous` and issue just one `AcquisitionStart` command; 3) increase frame queue to 4-8 frames at least (`FRAMESCOUNT`). – dkz Mar 30 '14 at 07:02
  • Okay I did what you said and with frame rate 15 it's working here is my file https://db.tt/HkquECe5 It also works with setting frame rate 30 but, the video doesn't look like 30fps, it has some latency( I guess which can't be removed because I increased the framscount) and it looks like 4-5 fps if I move my hand fast it doesn't show the full path only discrete positions but it is setted to 30 fps because I can see my output: https://db.tt/0GjF0ysT . how can I improve my video at 30fps ? My video at 30fps https://db.tt/s0bSr4gY (at this link). – user3217310 Mar 31 '14 at 04:43
  • I think the latency and the video speed are coming from your QT image processing. Try measuring how much ms it will take from `QImage` construction till `label->show()` (including). This time should be less than 33 ms in order to keep up with 30fps frame rate. Also calling `doWork()` on timer event every 1ms is not efficient. It would be better to switch to FrameDoneCB callbacks later, but I don't think this is the cause of the slow down. Anyway if you can confirm that `CameraStart()` part can receive frames at 30fps without loosing any, it meas the problem is on the QT frame displaying part. – dkz Mar 31 '14 at 18:16
  • Well I guess I will try to remove the latency etc. but first I am want to see a color image, SO I was trying on that... I am able to get https://www.dropbox.com/s/jtumt7qsduez1fq/IMG_20140402_140217.jpg this image in colored format but it only comes after some seconds, and stops at this only this. The modified header file is https://www.dropbox.com/s/g3jpjjqdidyiui6/imageviewer.h . Have you ever come across such situation? do you how can I resolve it? https://www.dropbox.com/s/ht5kh23jd172ucj/Screenshot%20from%202014-04-02%2016%3A36%3A44.png in this I printed the content of frames.imagebuffer – user3217310 Apr 02 '14 at 07:39
  • Hi,Thanks! I checked few things that when I am taking the bayerrg8 data from camera the frames.status is success, and frames.imagesize parameter is 1360*1024 and imagebuffer is also 1360*1024 but when I set it in rgb24 mode the frames.status is datamissing error and the frames.imagebuffer is 1360*1024 but the frames.imagesize becomes zero. does this thing gives any clue ? and at all the steps where I am setting the parameters I have cross checked the statuses, all the settings I am are actually happening. the frames.format is 4 which means it is giving rgb24 data. – user3217310 Apr 03 '14 at 02:44
  • Your screenshot and "data missing" frame status for RGB format tells that several (many) packets were lost for this frame. This might happen among other things because of low performance of your client platform. Handling (displaying) 1.3Mpix @ 30pfs on embedded platform is not a trivial task. Doing de-Bayering at this speed almost impossible on slow CPU without special hardware support. You can try to slow down incoming traffic increasing inter-packet delay (integer parameter `GevSCPD` if camera supports it). Or you can try increasing processing power by using a modern PC. – dkz Apr 03 '14 at 06:49
  • Hey thanks for being with me ... I reduced the size of RGBimage to 800*800 and frame rate 30 it works fine at this. I am using Framescount value 6. But when I increase the image resolution to 1000*1000 or 1360*1024 ( at 30fps) It doesn't enqueue the 6 imgbffr so print an image then stop for some time and then again print one image then stop for quite some time. SO in the low resolution 800*800 it prints the for loop which I have for enqueue and print the it 6 times, but in the higher resolution only print the content inside it one time and moves on.am i clear enough or I should add images? – user3217310 Apr 03 '14 at 12:18
  • Also I have installed linux on my zynq processor so I guess debayring is actually happening in the Zynq processor. I use my PC/ computer to just make the project and using a tftp protocol I send the Linux Executable to the zynq board linux and the file run on that. okay I found the BandwidthCtrlMode - SCPD mode, my camera supports it I guess. I will try to do something with it and let you what I get. – user3217310 Apr 03 '14 at 12:26
  • Again I think your problems with image buffers are coming from the packet loss. Which in turn comes from the weak platform you're trying to use for this task. Zynq could work only if it's re-enforced with image processing cores on FPGA, so that all data processing is offloaded from the main CPU. Otherwise even dual-core ARM might not keep up with number crunching at this speed. At this point I'd suggest you re-evaluate your project goals and means to be sure you're not on mission impossible. – dkz Apr 04 '14 at 06:40
  • Also How can I increase the value of integer SCPD, I could only find a function which sets the bandwidth control mode to SCPD PvAttrEnumSet(GCamera.Handle,"BandwidthCtrlMode","SCPD"); but as you said in your previous comment that maybe I can increase the value of it? is it related to timestampsHi and Low parameters ?.. and yes thanks for guiding me you are awesome !!! – user3217310 Apr 04 '14 at 07:11
  • Also is it possible for me to add you on fb or something (mail,skype) anything please. – user3217310 Apr 04 '14 at 07:21
  • I think you are right as my board's GigE port limit it 115,000,000 bytesperseconds and if I take the RGB data at 30fps,1320*1024 then the rate is more than this. and Yes I have done all this in PS block of zynq , in the PL block I can I can use the VHDL to process the data at high rate but in that case I will have to create the image using VHDL for the HDMI port. Also about the SCPD, it is there I guess but in the camera manual it is written that that mode is not recommended so I am not sure wheter to use that mode or not. – user3217310 Apr 04 '14 at 07:37
  • `SCPD` is GigE Vision optional register that has fixed address of `0xd08` and 32 bit size, but I'm not sure if PvAPI gives access to it. It uses the same time units as timestamps do to set delay between two data packets. Anyway it would not help you on a longer run, since you actually want your stream to be faster, not slower. You can leave your contact email in the public section of your stackoverflow profile and I'll contact you tomorrow ('cause I'm on UTC-8 time zone). – dkz Apr 04 '14 at 07:56