<div dir="ltr"><div class="gmail_quote">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr">Hello everybody, and pleased to join this mailing list.<br><br>I&#39;m actually trying to develop a video processing application for the nokia (face detection &amp; expression recognition).<br><br>I got that stuff working on a PC with a webcam. (probably not yet optimised enough for the nokia, but that&#39;s the next part !)<br>
I configured maemo environment (using diablo) and finally got the example_camera.c from maemo_example working.<br>So I used the structure of this one for my application. But I&#39;m not sure yet how the pipeline thing works, I wasn&#39;t able to get any result :(<br>
<br>Here is my pipeline :<br><br><br><br>static gboolean initialize_pipeline(AppData *appdata,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int *argc, char ***argv)<br>{<br>&nbsp;&nbsp;&nbsp; GstElement *pipeline, *camera_src, *screen_sink;<br>&nbsp;&nbsp;&nbsp; GstElement *screen_queue;<br>
&nbsp;&nbsp;&nbsp; GstElement *csp_filter, *tee;<br>&nbsp;&nbsp;&nbsp; GstCaps *caps;<br>&nbsp;&nbsp;&nbsp; GstBus *bus;<br><br><br>&nbsp;&nbsp;&nbsp; /* Initialize Gstreamer */<br>&nbsp;&nbsp;&nbsp; gst_init(argc, argv);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; /* Create pipeline and attach a callback to it&#39;s<br>&nbsp;&nbsp;&nbsp; &nbsp;* message bus */<br>
&nbsp;&nbsp;&nbsp; pipeline = gst_pipeline_new(&quot;test-camera&quot;);<br><br>&nbsp;&nbsp;&nbsp; bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));<br>&nbsp;&nbsp;&nbsp; gst_bus_add_watch(bus, (GstBusFunc)bus_callback, appdata);<br>&nbsp;&nbsp;&nbsp; gst_object_unref(GST_OBJECT(bus));<br>
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; /* Save pipeline to the AppData structure */<br>&nbsp;&nbsp;&nbsp; appdata-&gt;pipeline = pipeline;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; /* Create elements */<br>&nbsp;&nbsp;&nbsp; /* Camera video stream comes from a Video4Linux driver */<br>&nbsp;&nbsp;&nbsp; camera_src = gst_element_factory_make(VIDEO_SRC, &quot;camera_src&quot;);<br>
&nbsp;&nbsp;&nbsp; /* Colorspace filter is needed to make sure that sinks understands<br>&nbsp;&nbsp;&nbsp; &nbsp;* the stream coming from the camera */<br>&nbsp;&nbsp;&nbsp; csp_filter = gst_element_factory_make(&quot;ffmpegcolorspace&quot;, &quot;csp_filter&quot;);<br>
&nbsp;&nbsp;&nbsp; /* Tee that copies the stream to multiple outputs */<br>&nbsp;&nbsp;&nbsp; tee = gst_element_factory_make(&quot;tee&quot;, &quot;tee&quot;);<br>&nbsp;&nbsp;&nbsp; /* Queue creates new thread for the stream */<br>&nbsp;&nbsp;&nbsp; screen_queue = gst_element_factory_make(&quot;queue&quot;, &quot;screen_queue&quot;);<br>
&nbsp;&nbsp;&nbsp; /* Sink that shows the image on screen. Xephyr doesn&#39;t support XVideo<br>&nbsp;&nbsp;&nbsp; &nbsp;* extension, so it needs to use ximagesink, but the device uses<br>&nbsp;&nbsp;&nbsp; &nbsp;* xvimagesink */<br>&nbsp;&nbsp;&nbsp; screen_sink = gst_element_factory_make(VIDEO_SINK, &quot;screen_sink&quot;);<br>
<br><br>&nbsp;&nbsp;&nbsp; /* Check that elements are correctly initialized */<br>&nbsp;&nbsp;&nbsp; if(!(pipeline &amp;&amp; camera_src &amp;&amp; screen_sink &amp;&amp; csp_filter &amp;&amp; screen_queue))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_critical(&quot;Couldn&#39;t create pipeline elements&quot;);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FALSE;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; /* Add elements to the pipeline. This has to be done prior to<br>&nbsp;&nbsp;&nbsp; &nbsp;* linking them */<br>&nbsp;&nbsp;&nbsp; gst_bin_add_many(GST_BIN(pipeline), camera_src, csp_filter,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tee, screen_queue, screen_sink, NULL);<br>
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; /* Specify what kind of video is wanted from the camera */<br>&nbsp;&nbsp;&nbsp; caps = gst_caps_new_simple(&quot;video/x-raw-rgb&quot;,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;width&quot;, G_TYPE_INT, 640,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;height&quot;, G_TYPE_INT, 480,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;framerate&quot;, GST_TYPE_FRACTION, 25, 1,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; NULL);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; /* Link the camera source and colorspace filter using capabilities<br>&nbsp;&nbsp;&nbsp; &nbsp;* specified */<br>&nbsp;&nbsp;&nbsp; if(!gst_element_link_filtered(camera_src, csp_filter, caps))<br>
&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FALSE;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; gst_caps_unref(caps);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; /* Connect Colorspace Filter -&gt; Tee -&gt; Screen Queue -&gt; Screen Sink<br>&nbsp;&nbsp;&nbsp; &nbsp;* This finalizes the initialization of the screen-part of the pipeline */<br>
&nbsp;&nbsp;&nbsp; if(!gst_element_link_many(csp_filter, tee, screen_queue, screen_sink, NULL))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FALSE;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; /* gdkpixbuf requires 8 bits per sample which is 24 bits per<br>&nbsp;&nbsp;&nbsp; &nbsp;* pixel */<br>&nbsp;&nbsp;&nbsp; caps = gst_caps_new_simple(&quot;video/x-raw-rgb&quot;,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;width&quot;, G_TYPE_INT, 640,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;height&quot;, G_TYPE_INT, 480,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;bpp&quot;, G_TYPE_INT, 24,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;depth&quot;, G_TYPE_INT, 24,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; NULL);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br><br><br>// PROCESSING PART //<br><br><br><br>&nbsp;&nbsp;&nbsp; int x, y, expression;<br>&nbsp;&nbsp;&nbsp; double t;<br><br><br>&nbsp;&nbsp;&nbsp; // facedetected contain the face detected by viola and jones detector, original size<br>&nbsp;&nbsp;&nbsp; IplImage *facedetected&nbsp;&nbsp; = NULL;<br>
&nbsp;&nbsp;&nbsp; // faceresized contain the detected face scaled to 108*147<br>&nbsp;&nbsp;&nbsp; IplImage *faceresized = cvCreateImage(cvSize(108,147),IPL_DEPTH_8U , 1);<br>&nbsp;&nbsp;&nbsp; // faceresized2 contain the face in faceresized with 2 pixels black borders around<br>
&nbsp;&nbsp;&nbsp; IplImage *faceresized2 = cvCreateImage(cvSize(112,151),IPL_DEPTH_8U , 1);<br><br><br><br><br>&nbsp;&nbsp;&nbsp; // Plane that will hold current frame data<br>&nbsp;&nbsp;&nbsp; FLY_U8PlaneType&nbsp;&nbsp;&nbsp; *pcurrYPlane;<br>&nbsp;&nbsp;&nbsp; pcurrYPlane=(FLY_U8PlaneType *) malloc (sizeof(FLY_U8PlaneType));<br>
<br>&nbsp;&nbsp;&nbsp; // allocating space for image<br>&nbsp;&nbsp;&nbsp; pcurrYPlane-&gt;Width&nbsp; = 640;<br>&nbsp;&nbsp;&nbsp; pcurrYPlane-&gt;Height = 480;<br>&nbsp;&nbsp;&nbsp; pcurrYPlane-&gt;Stride = 640;<br>&nbsp;&nbsp;&nbsp; pcurrYPlane-&gt;Buffer = (unsigned char*)calloc(IMAGE_WIDTH*IMAGE_HEIGHT,sizeof(unsigned char *));<br>
&nbsp;&nbsp;&nbsp; <br><br><br><br><br><br>// Here is the image processing part<br><br><br><br><br><br>&nbsp;&nbsp;&nbsp; /* As soon as screen is exposed, window ID will be advised to the sink */<br>&nbsp;&nbsp;&nbsp; g_signal_connect(appdata-&gt;screen, &quot;expose-event&quot;, G_CALLBACK(expose_cb),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;screen_sink);<br>&nbsp;&nbsp;&nbsp; <br><br><br><br>&nbsp;&nbsp;&nbsp; gst_element_set_state(pipeline, GST_STATE_PAUSED);&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; return TRUE;<br>}<br><br><br><br><br>First, I&#39;d like to know if the way I&#39;m doing this is right. Should the processing part be in the pipeline initialisation function ? Or where should I put ? I need to process the maximum number of frames from the camera that the power of the arm processor permit.<br>
<br>My other problem is that I need to modify the buffer that will be displayed, to draw rectangles over the faces for instance. <br>So I&#39;d like to know how to access the buffer from the video_sink element, how is it ordered and how to modify the values of pixels.<br>
<br><br>I hope my questions are understandable, I&#39;m not really used to object languages and don&#39;t really get every aspect of gstreamer.<br>Thanks a lot for your attention, and have a nice week end !<br><br>Bruno<br>
<br></div><br></div><br></div></div><br></div>