Active Topics

 


Reply
Thread Tools
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#1
Hi all,

I'm willing to test GStreamer applications on Fremantle hardware.

It would really help multimedia developers if someone could provide GStreamer Editor for Fremantle, to help figure out how to build correct pipelines.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 

The Following 8 Users Say Thank You to qole For This Useful Post:
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#2
Ok, basic gstreamer pipeline from camera to screen:

v4l2src device=/dev/video0 ! autovideosink

For high resolution (back) camera, it is /dev/video0 and for the front web camera, it is /dev/video1.

The output needs to be massaged, so that the aspect ratio is correct, etc.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 

The Following 4 Users Say Thank You to qole For This Useful Post:
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#3
Can you change the self.player line to the one below and try again. Post the output here.

Code:
self.player = gst.parse_launch ('v4l2src device=/dev/video0 ! video/x-raw-yuv,width=320,height=240,framerate=(fraction)15/1 ! autovideosink')
__________________
N9: Go white or go home
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#4
Just trying that pipeline from the command line (gst-launch), I start getting "cannot negotiate format" as soon as I start adding the width, height, or framerate values...

How do you check what the device's capabilities are? There's got to be a way to query the device for acceptable parameters...
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#5
Use the following generic string instead. It should either work or dump out an error message with some width/height info.

Code:
self.player = gst.parse_launch ('v4l2src device=/dev/video0  ! autovideosink')
Is the lense cap off?
__________________
N9: Go white or go home
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#6
Yes, that very simple pipeline works. It displays the back camera's view in a square window in the middle of the screen (above your two buttons). I'd post a screenshot, but it appears that the screenshot utility doesn't capture the picture, just a black square where the picture is.

There was no output on the command line.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 

The Following 3 Users Say Thank You to qole For This Useful Post:
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#7
Just a note for future reference, since it is in a completely different thread; daperl's original camera script can be found here.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 
Posts: 2,102 | Thanked: 1,309 times | Joined on Sep 2006
#8
Ok, so the output of the large camera is 640 x 492 encoded as YUYV.
 
Posts: 2,102 | Thanked: 1,309 times | Joined on Sep 2006
#9
Actually although that gives you good Y data, the U and V data are probably arranged a little differently in the data stream (as for each of these you get two images side by side).

More testing...
 
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#10
The script you pointed to doesn't really do anything. The following really, really bad hack will actually take a picture and create a .png file on an n800. As is, it won't work on an n900, but the changes should be obvious.

Also, the file creation is really, really slow; about 25 seconds. It's strictly just a hard-coded, proof-of-concept that a picture can be taken on a tablet with just using PyGTK and GStreamer. Obviously, plenty of room for improvement.

Code:
#! /usr/bin/env python

import string
import gtk
import gst

class ShowMe:
	def __init__(self):
		window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		window.set_title("Webcam-Viewer")
		window.connect("destroy", gtk.main_quit, "WM destroy")
		vbox = gtk.VBox()
		window.add(vbox)
		self.movie_window = gtk.DrawingArea()
		vbox.add(self.movie_window)
		hbox = gtk.HBox()
		vbox.pack_start(hbox, False)
		hbox.set_border_width(10)
		hbox.pack_start(gtk.Label())
                self.takePicture = 0
		self.button0 = gtk.Button("Snap")
		self.button0.connect("clicked", self.onTakePicture)
		hbox.pack_start(self.button0, False)
		self.button = gtk.Button("Start")
		self.button.connect("clicked", self.start_stop)
		hbox.pack_start(self.button, False)
		self.button2 = gtk.Button("Quit")
		self.button2.connect("clicked", self.exit)
		hbox.pack_start(self.button2, False)
		hbox.add(gtk.Label())
		window.show_all()

                if 1 == 1:
                    self.player = gst.Pipeline('ThePipe')
                    src = gst.element_factory_make("gconfv4l2src", "src")
                    self.player.add(src)
                    for p in src.pads():
                        #print p.get_caps().to_string()
                        print p.get_name()
                    caps = gst.element_factory_make("capsfilter", "caps")
                    caps.set_property('caps', gst.caps_from_string(
                        'video/x-raw-rgb,width=352,height=288,bpp=16,depth=16,\
                        framerate=15/1'))
                    #caps.set_property('caps', gst.caps_from_string(
                        #'video/x-raw-rgb,width=352,height=288,\
                        #framerate=15/1'))
                        #red_mask=224,green_mask=28,blue_mask=3,framerate=15/1'))
                    self.player.add(caps)
                    filt = gst.element_factory_make("ffmpegcolorspace", "filt")
                    self.player.add(filt)
                    caps2 = gst.element_factory_make("capsfilter", "caps2")
                    caps2.set_property('caps', gst.caps_from_string(
                        'video/x-raw-rgb,width=352,height=288,bpp=16,depth=16,\
                        framerate=15/1'))
                    self.player.add(caps2)
                    sink = gst.element_factory_make("xvimagesink", "sink")
                    self.player.add(sink)
                    pad = src.get_pad('src')
                    pad.add_buffer_probe(self.doBuffer)
                    src.link(caps)
                    caps.link(filt)
                    filt.link(caps2)
                    caps2.link(sink)

		# Set up the gstreamer pipeline
		#self.player = gst.parse_launch ('gconfv4l2src ! video/x-raw-yuv,width=352,height=288,framerate=(fraction)15/1 ! autovideosink')
		#self.player = gst.parse_launch ('gconfv4l2src ! video/x-raw-yuv,width=352,height=288,framerate=(fraction)15/1 ! tee name=qole qole. ! ffmpegcolorspace ! queue ! filesink location=qole.raw qole. ! queue ! autovideosink')
		#self.player = gst.parse_launch ('gconfv4l2src ! video/x-raw-rgb,width=352,height=288,framerate=(fraction)15/1 ! tee name=qole qole. ! ffmpegcolorspace ! jpegenc ! filesink location=qole.raw qole. ! queue ! autovideosink')
		#self.player = gst.parse_launch ('v4l2src ! autovideosink')

		bus = self.player.get_bus()
		bus.add_signal_watch()
		bus.enable_sync_message_emission()
		bus.connect("message", self.on_message)
		bus.connect("sync-message::element", self.on_sync_message)

	def onTakePicture(self, w):
            self.takePicture = 1

	def doBuffer(self, pad, buffer):
            if self.takePicture:
                self.takePicture = 0
                #print buffer.get_caps()
                # 63488 2016 31
                # 0xf8  0x07,0xe0  0x1f
                p = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,352,288)
                pa = p.get_pixels()
                pal = list(pa)
                for i in range(0,len(buffer)/2):
                    pal[i*3] = "%c" % (0xf8 & ord(buffer[i*2+1]))
                    pal[i*3+1] = "%c" % (((0x07 & ord(buffer[i*2+1])) << 5) |\
                        ((0xe0 & ord(buffer[i*2])) >> 5))
                    pal[i*3+2] = "%c" % ((0x1f & ord(buffer[i*2])) << 3)
                js = string.join(pal,'')
                pb = gtk.gdk.pixbuf_new_from_data(js,gtk.gdk.COLORSPACE_RGB,                        False,8,352,288,1056)
                pb.save('/home/user/MyDocs/.images/daperl00.png','png')
                print pb.get_width(),pb.get_height()
            return True

	def start_stop(self, w):
		if self.button.get_label() == "Start":
			self.button.set_label("Stop")
			self.player.set_state(gst.STATE_PLAYING)
		else:
			self.player.set_state(gst.STATE_NULL)
			self.button.set_label("Start")

	def exit(self, widget, data=None):
		gtk.main_quit()

	def on_message(self, bus, message):
		t = message.type
		if t == gst.MESSAGE_EOS:
			self.player.set_state(gst.STATE_NULL)
			self.button.set_label("Start")
		elif t == gst.MESSAGE_ERROR:
			err, debug = message.parse_error()
			print "Error: %s" % err, debug
			self.player.set_state(gst.STATE_NULL)
			self.button.set_label("Start")

	def on_sync_message(self, bus, message):
		if message.structure is None:
			return
		message_name = message.structure.get_name()
		if message_name == "prepare-xwindow-id":
			# Assign the viewport
			imagesink = message.src
			imagesink.set_property("force-aspect-ratio", True)
			imagesink.set_xwindow_id(self.movie_window.window.xid)

if __name__ == "__main__":
    gtk.gdk.threads_init()
    ShowMe()
    gtk.main()
__________________
N9: Go white or go home
 

The Following 3 Users Say Thank You to daperl For This Useful Post:
Reply

Tags
camera, fremantle, gstreamer, maemo 5


 
Forum Jump


All times are GMT. The time now is 22:09.