the problem is the RGB is swapped, this is pretty common, before uploading to the texture you can use ofPixels::swapRGB or just use BGR when doing loadData on the texture
I tried it, but it didnt’t do the job. I’m suspecting the videograbber is choosing a wrong format for the camera- is there a way to force use raw-bayer instead of raw-rgb? I’ve got some logs here:
[verbose] ofGstVideoGrabber: get_device_data(): device: DFx 31AU03(/dev/video0)
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw-yuv 1024x768 framerates:
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw-bayer 1024x768 framerates:
[verbose] ofGstVideoGrabber: add_video_format(): more similar framerate replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw-gray 1024x768 framerates:
[verbose] ofGstVideoGrabber: add_video_format(): already added, skipping
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw-yuv 1024x768 framerates:
[verbose] ofGstVideoGrabber: add_video_format(): non compressed format with same framerate, replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw-yuv 1024x768 framerates:
[verbose] ofGstVideoGrabber: add_video_format(): already added, skipping
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw-rgb 1024x768 framerates:
[verbose] ofGstVideoGrabber: add_video_format(): rgb format with same framerate as yuv, replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw-rgb 1024x768 framerates:
I still haven’t managed to get the correct camera image. I’ll be trying again and will update this post here. In the meanwhile, I would be very happy about any suggestions what else to do, if swapRGB doesn’t do it.
you should only update the pixels when there’s a new frame or you’ll be swapping rgb back and forth every frame of the application, doing thi instead of using an ofImage should be faster since you don’t need to move the pixels in memory or make copies just upload the pixels as BGR to a texture
That doesn’t work either. I even tried to get the pixelsref, swaprgb it and then upload it as GL_RGB, too, but without changing the image in the slightest bit. It looks like the color channel swapping isnt applied at all.
might be a problem with gstreamer then, latest versions of OF still work with gstreamer 0.10 (the one that comes with 12.04) but are more tested and work better with gstreamer 1.0, i would try with a computer with 14.04 if you don’t want to update the one you are using yet.
Okay, I’ve just installed gstreamer1.0 on my 12.04 machine, relaunched the install_* scripts and now I can’t seem to compile ofGstVideoGrabber/ofGstUtils anymore.
../../../libs/openFrameworksCompiled/lib/linux64/libopenFrameworksDebug.a(ofGstVideoGrabber.o)||In function `get_device_data':|
/home/mrzl/devel/sco/0124_app/application/deps/of_v081_linux64_release/libs/openFrameworksCompiled/project/../../../libs/openFrameworks/video/ofGstVideoGrabber.cpp|563|undefined reference to `gst_caps_unref'|
../../../libs/openFrameworksCompiled/lib/linux64/libopenFrameworksDebug.a(ofGstUtils.o)||In function `on_new_buffer_from_source':|
/home/mrzl/devel/sco/0124_app/application/deps/of_v0.8.1_linux64_release/libs/openFrameworksCompiled/project/../../../libs/openFrameworks/video/ofGstUtils.cpp|45|undefined reference to `gst_app_sink_pull_buffer'|
../../../libs/openFrameworksCompiled/lib/linux64/libopenFrameworksDebug.a(ofGstUtils.o)||In function `ofGstUtils::setPipelineWithSink(_GstElement*, _GstElement*, bool)':|
/home/mrzl/devel/sco/0124_app/application/deps/of_v0.8.1_linux64_release/libs/openFrameworksCompiled/project/../../../libs/openFrameworks/video/ofGstUtils.cpp|186|undefined reference to `gst_plugin_feature_get_name'|
../../../libs/openFrameworksCompiled/lib/linux64/libopenFrameworksDebug.a(ofGstUtils.o)||In function `ofGstVideoUtils::update()':|
/home/mrzl/devel/sco/0124_app/application/deps/of_v0.8.1_linux64_release/libs/openFrameworksCompiled/project/../../../libs/openFrameworks/video/ofGstUtils.cpp|753|undefined reference to `gst_app_sink_pull_buffer'|
||=== Build finished: 4 errors, 0 warnings ===|
So, I’ve just tried on a 14.04 LTS machine and the problem is still there. Whenever somebody may have an idea, let me know. I will post my own updates here:
This indicates that gstreamer doesn’t debayer the video image. Is there a way to manually force-set the video format gstreamer uses to bayer in order to get data from the camera that is interpreted in the right way? As I wrote in one of my first posts, when enabling verbose mode in VideoGrabber, you can see that ofGstVideoGrabber decides for x-raw-rgb, whereas x-raw-bayer or x-raw-yuv should be chosen, as those are the pixel formats of the camera.
there’s several bayer formats, i’ve written the pipeline with the first one but if the image looks weird or it doesn’t work you can also try with bggr, grbg, gbrg, rggb
The app doesn’t crash and I don’t get a camera imagebut weird errors instead:
[ error ] ofGstUtils: setPipelineWithSink(): couldn't create pipeline: no element "videoconvert"
CRITICAL **: gst_v4l2src_fixate: assertation 'G_VALUE_TYPE (v) == GST_TYPE_LIST' failed
WARNING **: bayer2rgb0: size500 is not a multiple of unit size 786432
great, i think the camera you are using might be reporting different formats while only supporting bayer so you need to setup the pipeline yourself. anyway, glad it’s working