Open devykrishna opened 5 years ago
It's interesting that it fails to grab the frame. Have you tried debugging it by adding GST_DEBUG=*:5
in front of the gst-launch-1.0 command and seeing if there's anything interesting there?
Either way, to achieve what want you will need to modify the source file (gstpylonsrc.c) and recompile the plugin.
One option would be to simply replace the line at https://github.com/zingmars/gst-pylonsrc/blob/2073177d915c9e729ba85b99bf0b8c863aceb0f4/plugins/gstpylonsrc.c#L2101 with return GST_FLOW_OK;
, but I'm not quite sure how other gstreamer plugins will react if they receive an empty buffer.
A better alternative would be to set a label (syntax - name:
) earlier in the function (like line 2056) and replace this line with a goto to this label (goto name;
) so that it just pulls a new frame instead. You will probably need to add https://github.com/zingmars/gst-pylonsrc/blob/2073177d915c9e729ba85b99bf0b8c863aceb0f4/plugins/gstpylonsrc.c#L2097 before the goto as well.
Sadly I no longer have access to Basler cameras and I can't really test it myself.
FYI if it helps, when I use GStreamer & pylon together, I use pylon's GrabStrategy_LatestImageOnly and try to set the framerate of the camera faster than what my pipeline needs. That way, the camera is always acquiring and transmitting, and Pylon is only holding the most recent image for retrieval. When the next one comes in, if the previous hasn't been retrieved it's just overwritten in memory. This can kind of give the best of both worlds (ignore the error and run with no errors is actually mutually exclusive :)) - if I'm acquiring at 60fps and running my pipeline at 30fps, then if I come across a bad image, I can log the error and hopefully the next good image comes in before the pipeline actually requests it.
Thanks for the reply. I modified the code as below. seems like issue is fixed.
if(grabResult.Status == Grabbed) {
//TODO: See if I can avoid memcopy and record directly into the gst buffer map.
// Copy the image into the buffer that will be passed onto the next GStreamer element
*buf = gst_buffer_new_and_alloc(pylonsrc->payloadSize);
gst_buffer_map(*buf, &mapInfo, GST_MAP_WRITE);
orc_memcpy(mapInfo.data, grabResult.pBuffer, mapInfo.size);
gst_buffer_unmap(*buf, &mapInfo);
// Release frame's memory
res = PylonStreamGrabberQueueBuffer( pylonsrc->streamGrabber, grabResult.hBuffer, (void*) bufferIndex );
PYLONC_CHECK_ERROR(pylonsrc, res);
// Set frame offset
GST_BUFFER_OFFSET(*buf) = pylonsrc->frameNumber;
pylonsrc->frameNumber += 1;
GST_BUFFER_OFFSET_END(*buf) = pylonsrc->frameNumber;
} else if ( grabResult.Status == Failed ){
GST_ERROR_OBJECT(pylonsrc, "Error in the image processing loop.");
*buf = gst_buffer_new_and_alloc(pylonsrc->payloadSize);
gst_buffer_map(*buf, &mapInfo, GST_MAP_WRITE);
orc_memcpy(mapInfo.data, grabResult.pBuffer, mapInfo.size);
gst_buffer_unmap(*buf, &mapInfo);
// Release frame's memory
res = PylonStreamGrabberQueueBuffer( pylonsrc->streamGrabber, grabResult.hBuffer, (void*) bufferIndex );
PYLONC_CHECK_ERROR(pylonsrc, res);
// Set frame offset
GST_BUFFER_OFFSET(*buf) = pylonsrc->frameNumber;
GST_BUFFER_OFFSET_END(*buf) = pylonsrc->frameNumber;
}
Actually I could not find the grab strategy currently using in pylonsrc. How can I set the grabbing strategy?
Thanks very much.
Hi all, Please see the gst pipeline I am using for streaming Basler camera, GST_DEBUG=pylonsrc:5 gst-launch-1.0 -v pylonsrc height=720 width=1280 fps=25 imageformat=mono8 ! videoconvert ! video/x-raw,format=BGR ! videoconvert ! autovideosink
with this I am able to stream vidoe successfully. But I want to feed the video frames to my application for further processing (using appsink _pylonsrc height=720 width=1280 fps=25 imageformat=mono8 ! videoconvert ! video/x-raw,format=BGR ! appsink max-buffers=5 drop=1 ).But its not working ,it seems like application is not receiving video frames at all. I can see few warning messages in the log. attaching the log below:
chevron@chevron-desktop:~/live$ GST_DEBUG=pylonsrc:5 gst-launch-1.0 -v pylonsrc height=720 width=1280 fps=25 imageformat=mono8 ! videoconvert ! video/x-raw,format=BGR ! videoconvert ! autovideosink
0:00:00.029706852 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:397:gst_pylonsrc_init:<GstPylonsrc@0x561cc1c518e0> Initialising defaults
0:00:00.029764255 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:477:gst_pylonsrc_set_property:<pylonsrc0> Setting a property.
0:00:00.029799369 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:477:gst_pylonsrc_set_property:<pylonsrc0> Setting a property.
0:00:00.029837221 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:477:gst_pylonsrc_set_property:<pylonsrc0> Setting a property.
0:00:00.029854555 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:477:gst_pylonsrc_set_property:<pylonsrc0> Setting a property.
0:00:00.031227094 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:871:gst_pylonsrc_get_caps:<pylonsrc0> Received a request for caps.
0:00:00.031239356 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:873:gst_pylonsrc_get_caps:<pylonsrc0> Could not send caps - no camera connected.
0:00:00.032089216 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:871:gst_pylonsrc_get_caps:<pylonsrc0> Received a request for caps.
0:00:00.032099055 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:873:gst_pylonsrc_get_caps:<pylonsrc0> Could not send caps - no camera connected.
0:00:00.032999994 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:871:gst_pylonsrc_get_caps:<pylonsrc0> Received a request for caps.
0:00:00.033010432 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:873:gst_pylonsrc_get_caps:<pylonsrc0> Could not send caps - no camera connected.
0:00:00.033841967 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:871:gst_pylonsrc_get_caps:<pylonsrc0> Received a request for caps.
0:00:00.033851298 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:873:gst_pylonsrc_get_caps:<pylonsrc0> Could not send caps - no camera connected.
0:00:00.035556670 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:871:gst_pylonsrc_get_caps:<pylonsrc0> Received a request for caps.
0:00:00.035567870 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:873:gst_pylonsrc_get_caps:<pylonsrc0> Could not send caps - no camera connected.
0:00:00.037238205 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:871:gst_pylonsrc_get_caps:<pylonsrc0> Received a request for caps.
0:00:00.037247912 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:873:gst_pylonsrc_get_caps:<pylonsrc0> Could not send caps - no camera connected.
0:00:00.038153616 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:871:gst_pylonsrc_get_caps:<pylonsrc0> Received a request for caps.
0:00:00.038163139 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:873:gst_pylonsrc_get_caps:<pylonsrc0> Could not send caps - no camera connected.
Setting pipeline to PAUSED ...
0:00:00.299778583 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:953:gst_pylonsrc_start:<pylonsrc0> pylonsrc: found 1 Basler device(s).
0:00:00.299841045 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:2198:pylonc_connect_camera:<pylonsrc0> Connecting to the camera...
0:00:00.709894608 454 0x561cc1c2eac0 pylonsrc gstpylonsrc.c:2243:pylonc_print_camera_info:<pylonsrc0> Status: Using camera "acA1920-40gm" (serial number: 0, id: 0). Custom ID: None
0:00:00.714194329 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1064:gst_pylonsrc_start:<pylonsrc0> Max resolution is 1936x1216.
0:00:00.719126222 454 0x561cc1c2eac0 pylonsrc gstpylonsrc.c:1093:gst_pylonsrc_start:<pylonsrc0> Setting resolution to 1280x720.
0:00:00.724120310 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1111:gst_pylonsrc_start:<pylonsrc0> Centering X: False, Centering Y: False.
0:00:00.726741083 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1157:gst_pylonsrc_start:<pylonsrc0> Flipping X: False, Flipping Y: False.
0:00:00.727963224 454 0x561cc1c2eac0 pylonsrc gstpylonsrc.c:1217:gst_pylonsrc_start:<pylonsrc0> Using Mono8 image format.
0:00:00.731420001 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1228:gst_pylonsrc_start:<pylonsrc0> Pixel is 8 bits large.
0:00:00.733565240 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:1269:gst_pylonsrc_start:<pylonsrc0> Camera does not support changing the readout mode.
0:00:00.733624418 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:1284:gst_pylonsrc_start:<pylonsrc0> Camera does not support disabling the throughput limit.
0:00:00.733676064 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:1299:gst_pylonsrc_start:<pylonsrc0> Camera does not support changing the throughput limit.
0:00:00.735001973 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1313:gst_pylonsrc_start:<pylonsrc0> Enabled custom framerate limiter. See below for current framerate.
0:00:00.735048279 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:1350:gst_pylonsrc_start:<pylonsrc0> This camera doesn't have any lightsource presets
0:00:00.736303914 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1357:gst_pylonsrc_start:<pylonsrc0> Disabling automatic exposure.
0:00:00.738188303 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1381:gst_pylonsrc_start:<pylonsrc0> Disabling automatic gain.
0:00:00.739650242 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:1422:gst_pylonsrc_start:<pylonsrc0> This camera doesn't support automatic white balance.
0:00:00.739684876 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1493:gst_pylonsrc_start:<pylonsrc0> Using the auto profile currently saved on the device.
0:00:00.743299402 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1664:gst_pylonsrc_start:<pylonsrc0> This camera doesn't support adjusting colours. Skipping...
0:00:00.748142850 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1786:gst_pylonsrc_start:<pylonsrc0> This camera doesn't support transforming colours. Skipping...
0:00:00.748213002 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:1803:gst_pylonsrc_start:<pylonsrc0> This camera doesn't support setting manual exposure.
0:00:00.748253287 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:1816:gst_pylonsrc_start:<pylonsrc0> This camera doesn't support setting manual gain.
0:00:00.748286853 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:1825:gst_pylonsrc_start:<pylonsrc0> This camera doesn't support setting black level.
0:00:00.748974170 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1830:gst_pylonsrc_start:<pylonsrc0> Setting gamma to 1.00
0:00:00.752944772 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1874:gst_pylonsrc_start:<pylonsrc0> Basler's PGI is not supported. Skipping.
0:00:00.752985511 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1878:gst_pylonsrc_start:<pylonsrc0> Setting trigger mode.
0:00:00.758807385 454 0x561cc1c2eac0 DEBUG pylonsrc gstpylonsrc.c:1922:gst_pylonsrc_start:<pylonsrc0> Using "FrameStart" trigger selector. Software trigger mode is Off.
0:00:00.772015746 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:2003:gst_pylonsrc_start:<pylonsrc0> Couldn't determine link speed.
0:00:00.772075465 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:2015:gst_pylonsrc_start:<pylonsrc0> Couldn't determine sensor readout time.
0:00:00.772115774 454 0x561cc1c2eac0 WARN pylonsrc gstpylonsrc.c:2028:gst_pylonsrc_start:<pylonsrc0> Couldn't determine the resulting framerate.
0:00:00.773114811 454 0x561cc1c2eac0 pylonsrc gstpylonsrc.c:2040:gst_pylonsrc_start:<pylonsrc0> Initialised successfully.
Pipeline is live and does not need PREROLL ...
0:00:00.773790647 454 0x561cc1c5fd90 DEBUG pylonsrc gstpylonsrc.c:871:gst_pylonsrc_get_caps:<pylonsrc0> Received a request for caps.
0:00:00.773874700 454 0x561cc1c5fd90 DEBUG pylonsrc gstpylonsrc.c:910:gst_pylonsrc_get_caps:<pylonsrc0> The following caps were sent: video/x-raw, GRAY8, 1280x720, variable fps.
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.775111169 454 0x561cc1c5fd90 DEBUG pylonsrc gstpylonsrc.c:921:gst_pylonsrc_set_caps:<pylonsrc0> Setting caps to video/x-raw, format=(string)GRAY8, width=(int)1280, height=(int)720, framerate=(fraction)0/1
/GstPipeline:pipeline0/GstPylonsrc:pylonsrc0.GstPad:src: caps = video/x-raw, format=(string)GRAY8, width=(int)1280, height=(int)720, framerate=(fraction)0/1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)BGR
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)BGR
/GstPipeline:pipeline0/GstVideoConvert:videoconvert1.GstPad:src: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)YV12
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)YV12
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage.GstPad:sink: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)YV12
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)YV12
/GstPipeline:pipeline0/GstVideoConvert:videoconvert1.GstPad:sink: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)BGR
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)BGR
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw, format=(string)GRAY8, width=(int)1280, height=(int)720, framerate=(fraction)0/1
I am totally unsure of what is going wrong. I hope you can guide me on this issue that I am facing. I really appreciate your help.
Code
It seems that you just copied the buffer copying code from the above block, at which point it was easier to just get rid of the if block altogether. The thing is, there's probably a reason why Pylon didn't mark the frame as grabbed, and you're probably getting incomplete frame there. That said, if it works for you, it's fine.
Actually I could not find the grab strategy currently using in pylonsrc. How can I set the grabbing strategy?
From what I can see in the docs GrabStrategy is a setting for the C++ API, while this plugin implements the C API. My guess the analogue would be to switch to trigger mode (continuous=false
) as it would explicitly request frames from the camera as opposed to copying the current frame in the camera's buffer.
Log
There doesn't seem to be anything wrong in the log. Is this log from a normal run?
Also a suggestion for the future, put all code and logs inbetween triple grave accents (```). I.e. ``` something /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)YV12 something ``` becomes
something
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink: caps = video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)0/1, format=(string)YV12
something
This will make things slightly more readable as it doesn't wrap the lines.
Hi zingmars,
code
In else block I have omitted the line
pylonsrc->frameNumber += 1;
Log What you mean by normal run? This log I generated by running the gst-launch-1.0 command. I have to feed gstreamer pipeline (as below) to my application, which is not working.
pylonsrc height=720 width=1280 fps=25 imageformat=mono8 ! videoconvert ! video/x-raw,format=BGR ! appsink max-buffers=5 drop=1
Please let me know if you need anything else from me.
There doesn't seem to be anything that indicates an error in that log. In fact, the command you used for that log sent all output to autovideosink (which as I understand works for you) and not appskink. It's also a bit hard to tell what's going on with your appsink without knowing how you're pulling data and what's happening (is no data being buffered? can you even get GstSample out of it?). Tbf even then I'm not sure if I can help much with appsink, as we used this plugin to write to shared memory instead.
we used this plugin to write to shared memory instead.
Does this mean that pylonsrc plugin has limitations to use with appsink?
No, It just means it was never tested with it so I don't really know what the issue could be.
On Mon, Apr 1, 2019, 08:28 DevySyam notifications@github.com wrote:
we used this plugin to write to shared memory instead. Does this mean that pylonsrc plugin has any limitations to use with appsink?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zingmars/gst-pylonsrc/issues/5#issuecomment-478440576, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3-hv6QBwNgHhJC6ko89MECB5EzM4jFks5vcZj0gaJpZM4cM-NJ .
Camera: Basler acA1300-75gc I do also have this error running:
GST_DEBUG=pylonsrc:5 gst-launch-1.0 -v \
pylonsrc continuous=false ! \
bayer2rgb ! \
videoconvert ! \
x264enc noise-reduction=10000 pass=4 quantizer=22 bitrate=32768 speed-preset=0 byte-stream=true tune="zerolatency" ! \
mpegtsmux ! \
tcpserversink port=8888
Error:
0:01:19.582882347 3385 0x5583ecf48590 ERROR pylonsrc gstpylonsrc.c:2100:gst_pylonsrc_create:<pylonsrc0> Error in the image processing loop.
BŁĄD: od elementu /GstPipeline:pipeline0/GstPylonsrc:pylonsrc0: Internal data stream error.
Dodatkowe informacje diagnostyczne:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstPylonsrc:pylonsrc0:
streaming stopped, reason error (-5)
UPD: Adding height=480 width=640
causes no error.
UPD2: Adding height=720 width=1280
causes also no error.
UPD3: height=720 width=1280
still errors after some time.
```0:00:00.015034389 3385 0x5583ecf0d2c0 DEBUG pylonsrc gstpylonsrc.c:397:gst_pylonsrc_init:
I've merged pylonsrc into gst-plugins-vision, and have been making some modifications including more comprehensive pixel format support, GStreamer caps negotiation instead of manually setting imageformat
, removed the mempcy by wrapping buffers, but I have been seeing this same error reported here.
As best I can tell, the Grabbed
result indicates the entire frame was received without errors. If there's any corruption in the image, the result will be Failed
, even if most of the image was copied successfully. I can make this problem worse by reducing the packet size on my network adapter.
I'm thinking the best way to handle this is to have a property that will continue grabbing frames even if one is corrupted, and maybe another property that determines whether to pass or drop the corrupted frame.
I created a new issue on gst-plugins-vision for anyone who wants to give input.
I am using gst-pylonsrc for streaming Basler 1920 40 gm camera. I have added pylonsrc element and streaming video successfully. But after few min/few seconds stream stops and getting the following error. "Error in the image processing loop" I found that this error is coming when the grabresult is equal to failed even for single frame. I want to skip this error and need to stream video continuously without any errors. (Sometimes camera will stream for an hour and then throwing the error, and sometimes this happen within few seconds also.)
Kindly help me .