Tuesday, January 12, 2010

after thursday, I worked on creating the double-click function and uploading our Activity to sugarlabs.

[the post below contains my code for the double-click function]

Today I worked on making the sliders actually do something in Timelapse. This led to me writing the code in the post below.

By the end of the day, I had created a quality tab that actually worked for TimeLapse.

To make the values for video, only input width x height ratios of 4:3 and for audio values, I only input rates based on a 6,000 scale.

Because the coding would be to complicated to have the slider stop at specific values, I just made Timelapse give a value based upon where the slider is in proximity with the closest value.

For example, if the slider goes to 2.76 then the code will use the value width = 256 & height = 192.

Computer

Double Click

def doubleclicked(self, data, third):
        if os.path.isfile(os.path.abspath(self.soundfile)):
            self.player.set_property("uri", "file://" +
                                     os.path.abspath(self.soundfile))
        self.player.set_state(gst.STATE_PLAYING)
        else:
           pass


Quality Tab

class Tab(interface.NewTab):
    def make(self):
        # change these to glade callbacks later.
        self.video, self.audio, self.image, self.lapse, self.width, self.height, self.rate = 4, 4, 4, 4, 100, 75, 12000

    def on_video_changed(self, widget):
        self.video = widget.get_value()
        print "video quality", self.video
    if self.video < 1.50:
        self.width = 100
        self.height = 75
    if self.video >= 1.50 and self.video < 2.50:
        self.width = 200
        self.height = 150
        print "optimal"
    if self.video >= 2.50 and self.video < 3.50:
        self.width = 256
        self.height = 192
    if self.video >= 3.50 and self.video < 4.50:
        self.width = 320
        self.height = 240
    if self.video >= 4.50 and self.video < 5.50:
        self.width = 400
        self.width = 300
    if self.video >= 5.50 and self.video <= 6.00:
        self.width = 512
        self.height = 384

    def on_audio_changed(self, widget):
        self.audio = widget.get_value()        
    print "audio quality", self.audio
    if self.audio < 1.50:
        self.rate = 12000
    if self.audio >= 1.50 and self.video < 2.50:
        self.rate = 18000
    if self.audio >= 2.50 and self.video < 3.50:
        self.rate = 24000
    if self.audio >= 3.50 and self.video < 4.50:
        self.rate = 30000
    if self.audio >= 4.50 and self.video < 5.50:
        self.rate = 36000
    if self.audio >= 5.50 and self.video <= 6.00:
        self.rate = 48000

Cameramic

 def video(self):
        VIDEO_GST_PIPE = ['v4l2src', 'queue', 'videorate',
                          'video/x-raw-yuv,framerate=15/1', 'videoscale',
                          'video/x-raw-yuv,width=%d,height=%d' % (qualitytab.tab.width, qualitytab.tab.height),
                          'ffmpegcolorspace', 'theoraenc', 'oggmux']
        pipe = VIDEO_GST_PIPE + ["filesink location=%s" % (self.video_temp)]
        self.video_pipe = gst.parse_launch('!'.join(pipe))
        self.video_pipe.set_state(gst.STATE_PLAYING)
    print qualitytab.tab.width
    print qualitytab.tab.height
            
    def audio(self):
        AUDIO_GST_PIPE = ["alsasrc",
                          "audio/x-raw-int,rate=%d,channels=1,depth=16" %
                          qualitytab.tab.rate, "audioconvert","flacenc"]
        pipe = AUDIO_GST_PIPE + ["filesink location=%s" % (self.audio_temp)]
        self.audio_pipe = gst.parse_launch('!'.join(pipe))
        self.audio_pipe.set_state(gst.STATE_PLAYING)
    print qualitytab.tab.rate        


Thursday, January 7, 2010

I just figure out how to make the sliders actual work, it all had to be done in glade and the answer came after thirty minutes of google searches.

http://tadeboro.blogspot.com/2009/09/glade3-tutorial-4-gtktreeview-data.html

I finally found this site, which told me to set the page_size = 0.00, after I did that and opened TimeLapse again, the sliders worked.
Worked on the slider bars under the quality tab today.
Making them functional and adding actual values to them.

For Video Quality, there will be six value:

Value 1 = 200 x 150
Value 2 = 256 x 192
Value 3 = 320 x 240
Value 4 = 400 x 300
Value 5 = 512 x 384
Value 6 = 640 x 480
Because the def image was not creating a snapshot, I wondered if maybe it was because of the Video function which was maybe conflicting with image, because we never set an order for the program. This means that it was trying to take a snapshot and record video at the same time. So you can see where this might have cause problems. We ended up having the computer take a picture first then record video and sound. So we changed the order in which they ran, making image run first then video and audio at the same time.

Tuesday, January 5, 2010

This involved making the image button function, so that when data was collected and image was taken and not just a video and sound.

def image(self):
self.image_path = "/tmp/tmp" + str(time.time())

IMAGE_GST_PIPE = ['v4l2src', 'ffmpegcolorspace', 'pngenc']
pipe = IMAGE_GST_PIPE + ['filesink location=%s' % (self.image_path)]
self.bus = self.pipe.get_bus()
self.pipe.set_state(gst.STATE_PLAYING)
self.bus.poll(gst.MESSAGE_EOS, -1)

self.file_dsobject = datastore.create()
self.file_dsobject.metadata['title'] = "Image Sample"
self.file_dsobject.metadata['mime_type'] = 'image/png'
self.file_dsobject.set_file_path(self.image_path)
datastore.write(self.file_dsobject)
self.file_dsobject.destroy()
Peter ended up changing the entire interface but had not had time to actually make all of the buttons and objects functional. This meant I spent most of today fixing this problem when I was not working on the video issue.