Reply
Thread Tools
Posts: 38 | Thanked: 2 times | Joined on Apr 2010 @ Novosibirsk, Russia
#1
Hello!
I start to develop simple camera app for N900 with GDigicam lib. And I stuck with it. Let me show you my code:

All of camera action is in Qt GDigicamWidget. I try to create and configure camerabin like so:

Code:
GDigicamWidget::GDigicamWidget(QWidget* parent) : QWidget(parent)
{
	g_digicam_init (0, 0);

	GError* gerror = new GError();
	GstElement* camera_src = NULL;
	GstElement* screen_sink = NULL;
	GstElement* image_sink = NULL;

	GstElement* csp_filter = NULL;
	GstElement* image_filter = NULL;
	GstElement* tee = NULL;

	GstElement* screen_queue = NULL;
	GstElement* image_queue = NULL;
	GstCaps*    caps = NULL;

	camera_bin = gst_bin_new (NULL);

    camera_src = gst_element_factory_make (VIDEO_SRC, "camera_src");
    csp_filter = gst_element_factory_make ("ffmpegcolorspace", "csp_filter");
    screen_sink = gst_element_factory_make (VIDEO_SINK, "screen_sink");

    tee = gst_element_factory_make("tee", "tee");
    screen_queue = gst_element_factory_make("queue", "screen_queue");
    image_queue = gst_element_factory_make("queue", "image_queue");
    image_filter = gst_element_factory_make("ffmpegcolorspace", "image_filter");
    image_sink = gst_element_factory_make("fakesink", "image_sink");

    gst_bin_add_many(GST_BIN_CAST(camera_bin), camera_src, csp_filter,
    			tee, screen_queue, screen_sink, image_queue,
    			image_filter, image_sink, NULL);

    caps = gst_caps_new_simple("video/x-raw-yuv",
    			"format",  GST_TYPE_FOURCC, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'),
    			"width", G_TYPE_INT, 640,
    			"height", G_TYPE_INT, 480,
    			"bpp", G_TYPE_INT, 24,
    			"framerate", GST_TYPE_FRACTION, 25, 1,
    			NULL);

    gst_element_link_filtered(camera_src, csp_filter, caps);
    gst_caps_unref(caps);

    gst_element_link_many(csp_filter, tee, screen_queue, screen_sink, NULL);

    caps = gst_caps_new_simple("video/x-raw-rgb",
    			"width", G_TYPE_INT, 640,
    			"height", G_TYPE_INT, 480,
    			"bpp", G_TYPE_INT, 24,
    			NULL);

    gst_element_link_many(tee, image_queue, image_filter, NULL);
    gst_element_link_filtered(image_filter, image_sink, caps);
    gst_caps_unref(caps);
 
	descriptor = g_digicam_camerabin_descriptor_new(camera_bin);	
	manager = g_digicam_manager_new();
	g_digicam_manager_query_capabilities(manager, &descriptor, NULL);

	g_digicam_manager_set_gstreamer_bin(manager, camera_bin, descriptor, NULL);

	GDigicamCamerabinModeHelper* mode_helper = new GDigicamCamerabinModeHelper();
	mode_helper->mode = G_DIGICAM_MODE_STILL;
	if(!g_digicam_manager_set_mode(manager, G_DIGICAM_MODE_STILL, &gerror, mode_helper))
	{
		qDebug() << "GDigicamWidget::GDigicamWidget(): " << gerror->code << gerror->message;
	}
	g_digicam_manager_set_iso_sensitivity_mode(manager, G_DIGICAM_ISOSENSITIVITYMODE_AUTO, 400, NULL, NULL);
	g_digicam_manager_set_preview_mode(manager, G_DIGICAM_PREVIEW_ON, NULL, NULL);

	g_digicam_manager_play_bin(manager, this->winId(), NULL);
}
As you see I check what return, for example, method 'g_digicam_manager_set_mode' and they return me FALSE, then I try to get error code and message and get only error code 0 and no message in GError struct.

So, on the screen of N900 I see video stream from camera, but I can`t anyhow to manipulate it, Can`t autofocus, can`t get a shot.
 
FreeThinker's Avatar
Posts: 65 | Thanked: 36 times | Joined on Apr 2010 @ Las Vegas
#2
To actually get a picture from a GStreamer stream, you have to add a GstFakeSink element to your pipeline and listen for the handoff signal.

This signal is called once for every frame, so basically what you do to get one single still frame is:
  1. Connect a handler to the handoff signal of the fakesink element
  2. Do your thing with the raw frame buffer by manipulating the buffer argument that this handler is called with.
  3. Disconnect the signal handler

For more information on GstFakeSink see http://gstreamer.freedesktop.org/dat...-fakesink.html

As for the autofocus, I think that is some kind of Nokia binary blob that we can't really touch.
 

The Following 5 Users Say Thank You to FreeThinker For This Useful Post:
Posts: 38 | Thanked: 2 times | Joined on Apr 2010 @ Novosibirsk, Russia
#3
Oh, thanks! Taking photo now is work, although I`m doing something wrong with raw-data, because QImage are construct a broken image (I`m using Qt).
Code:
static gboolean buffer_probe_callback(GstElement *image_sink, GstBuffer *buffer, GstPad *pad, GDigicamWidget *widget)
{

	const uchar *data_photo = (const uchar *) GST_BUFFER_DATA(buffer);
	unsigned int iDataSize = buffer->size;
	QImage* img = new QImage(data_photo, 640, 480, QImage::Format_RGB16);

	if(img)
	{
		qDebug() << "BufferProbeCallBack(): QImage created";
		if(!img->save("/home/grinch/PIC001.bmp"))
		{
			qDebug() << "BufferProbeCallBack(): image not saved :(";
		}
		else
			qDebug() << "BufferProbeCallBack(): image saved!";
	}


	g_signal_handler_disconnect(G_OBJECT(image_sink), widget->iBufferID);
}

Regarding the focusing, I say that we can use focusing in our app, because Nokia don`t give us an API for this or what? GDigicam`s or Photography`s function like 'gst_photography_set_autofocus' will does`t work?
 
Posts: 432 | Thanked: 645 times | Joined on Mar 2009
#4
Originally Posted by Grinchman View Post
Regarding the focusing, I say that we can use focusing in our app, because Nokia don`t give us an API for this or what? GDigicam`s or Photography`s function like 'gst_photography_set_autofocus' will does`t work?
The autofocus in gdigicam should work as expected. you could check the code of the barcode-reader project to get a hint how it works.

Daniel
 

The Following 3 Users Say Thank You to danielwilms For This Useful Post:
FreeThinker's Avatar
Posts: 65 | Thanked: 36 times | Joined on Apr 2010 @ Las Vegas
#5
How is the pipeline set up? If the image you get out is messed up, you might be having colorspace problems.

EDIT: Assuming it looks something like the code in the first post, I'll make and educated guess and say that you've got a mismatch between the bpp you're sending to the fakesink and the format of the QImage. You send 24 bpp RGB to the sink, and yet your QImage is constructed with as a 16-bit RGB.

So, try calling your QImage constructor with QImage::Format_RGB888 and see if that helps.

Last edited by FreeThinker; 2010-05-04 at 00:43.
 

The Following 2 Users Say Thank You to FreeThinker For This Useful Post:
Posts: 38 | Thanked: 2 times | Joined on Apr 2010 @ Novosibirsk, Russia
#6
2FreeThinker: Yes, you was right! Now image is correct. Sorry for this, it is my first develop for multimedia, and I still do not quite know theory.

2danielwilms: I have investigated the barcode-reader, and yes, the autofocus should be implemented simply. It is interesting but the autofocus does not work in barcode-reader to! I compiled it from sources on Scratchbox for ARM target and run on Tablet via SBRSH. Maybe this problem?

EDIT: Another problem is that the last firmware of N900 has gdigicam-0.2.44 but the fremantle scratchbox has gdigicam-0.3.51. How to be if I want run my app directly on device? Is it possible to upgrade gdigicam lib in N900 to 0.3.51 version? Is need to add some source in the source list of apt?

Last edited by Grinchman; 2010-05-04 at 04:54.
 
FreeThinker's Avatar
Posts: 65 | Thanked: 36 times | Joined on Apr 2010 @ Las Vegas
#7
Originally Posted by Grinchman View Post

EDIT: Another problem is that the last firmware of N900 has gdigicam-0.2.44 but the fremantle scratchbox has gdigicam-0.3.51. How to be if I want run my app directly on device? Is it possible to upgrade gdigicam lib in N900 to 0.3.51 version? Is need to add some source in the source list of apt?
This is probably because the latest SDK is for PR 1.2 firmware, which isn't out for the device yet. Sadly, this has been the case for a number of months now, and nobody seems to know when said firmware is actually going to appear.

I hate to burst your bubble here, but you're probably going to have to wait until 1.2 shows up in order to test your app on the actual hardware. And just in case you're wondering, I don't know of any way to go back to the 1.1.1 SDK (it doesn't seem to be published anywhere anymore )
 
Posts: 38 | Thanked: 2 times | Joined on Apr 2010 @ Novosibirsk, Russia
#8
Ok, I should forget about direct run before new firmware is release.
But why focusing is not working while run on device via sbrsh?
 
Posts: 38 | Thanked: 2 times | Joined on Apr 2010 @ Novosibirsk, Russia
#9
New information.
I installed MADDE, configure Qt Creater and configured the device. Application is run on device fine, focusing is not working yet. But in debug mode i got such messages:
Code:
.dynamic section for "/home/grinch/.madde/0.6.14/sysroots/fremantle-arm-sysroot-2.2009-51-1-qt453/usr/lib/libgstreamer-0.10.so.0" is not at the expected address
difference appears to be caused by prelink, adjusting expectations
.dynamic section for "/home/grinch/.madde/0.6.14/sysroots/fremantle-arm-sysroot-2.2009-51-1-qt453/usr/lib/libglib-2.0.so.0" is not at the expected address
difference appears to be caused by prelink, adjusting expectations
It is because version of libraries in MADDE sysroots differs from libraries on device?
 

The Following User Says Thank You to Grinchman For This Useful Post:
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#10
 
Reply


 
Forum Jump


All times are GMT. The time now is 16:13.