Changes

Line 637: Line 637:     
Como en el Turtle Art V106 no es una construida en la muestra <i>psuedo-color.ta</i> que sólo difiere en que se carga la imagen de la revista en lugar de la cámara.
 
Como en el Turtle Art V106 no es una construida en la muestra <i>psuedo-color.ta</i> que sólo difiere en que se carga la imagen de la revista en lugar de la cámara.
 +
 +
 +
===Create your own 'camera' block with Python code===
 +
As of TurtleBlocksV106, this section has been largely superceded. The Show Camera block [[File:Show camera.jpg]] now has the function of the Python code and Show Media blocks [[File:Python show media.jpg]]. This information has been retained just to show how a little Python coding can be used to create your own 'show camera'.
 +
 +
 +
[[File:Captureta camera.jpg]]
 +
 +
Load the following code into the Python block [[File:Pythoncodeblock.jpg|40px]]
 +
 +
def myblock(lc, x):
 +
    import gst, time
 +
# grab a frame from camera to file
 +
    pipeline = gst.parse_launch('v4l2src ! ffmpegcolorspace ! jpegenc ! filesink location=/tmp/turtlepic.jpg')
 +
    pipeline.set_state(gst.STATE_PLAYING)
 +
# pause for a second to allow the camera frame to be grabbed
 +
    time.sleep(1)
 +
# stop the camera frame grabbing
 +
    pipeline.set_state(gst.STATE_NULL)
 +
 +
 +
This saves a photo to /tmp/turtlepic.jpg
 +
 +
 +
Here is the Turtle Art program as a doc file [[File:Camera ta.doc]].  The Show Media block is coded to point to the file /tmp/turtlepic.jpg
 +
 +
  ["journal", "/tmp/turtlepic.jpg"]
 +
 +
There are two ways to make the show media tile point to the file system and not the Journal
 +
 +
1 hand edit the code in the *.ta file with the Write Activity
 +
 +
2 Run Turtle Art under Gnome which has a file choser rather than a Journal object choser, the settings in the block are retained if the saved project is later run under Sugar
    
==Enlaces==
 
==Enlaces==
2,486

edits