. can direct_snapshot_previewWindow return picture location?
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    . can direct_snapshot_previewWindow return picture location?

    by anomad » Sat Jul 10, 2010 5:39 am

    . i'm working on my second interactive video piece called 'collage'

    . it lets the user move still frames of a video comprised of images/webding fonts and 'place' them on in the composition. when they're ready to go to the next image, i want to grab a screen capture, then load that into the next clip layer and let them choose another image.

    . is there a way to get the file location and file name of the image that i just captured with direct_snapshot_previewWindow ?

    . i know i can hardcode the directory that i set in preferences then import the os libraries in a module and grab the file name, then use direct_media_change to pull them image in and reset the media on the clip layer, but i'm looking for a slightly more elegant way of doing this.

    . or is that the elegant way to do it? :)

    -james
    (a nomad. )
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    by anomad » Sat Jul 10, 2010 7:44 am

    . ok, for the curious, this is my solution

    . in Init()
    import os

    . then i have a button that grabs the current preview and runs saveLiteToImage()

    . variable previously set:
    capturePath = '/Users/anomad/Desktop/collage' -- this mirrors the save preview files location in preferences
    workMedia = 2 -- the media id i'm going to load this into (bank 1, top row, 3rd from left)
    currentWork = 4 -- the clip layer i want the image to show up in. the user is manipulating layer 3. (layers 1 and 2 will have how to and other prompts being displayed)


    Code: Select all

    def saveLiveToImage() :
       modul8.setValue('direct_snapshot_mainOutput',1,0)
       if os.path.isdir(capturePath) :
          for fn in os.listdir(capturePath):
             myFN = capturePath+"/"+fn
          print myFN
          loadVal = workMedia,myFN
          modul8.setValue('direct_media_change',loadVal,currentWork)
          modul8.setValue('ctrl_layer_media',workMedia,currentWork)


    . so, i loop through the directory to get the last item (sorted by name, i'm guessing) - then i load that into the media set and reset currentWork layer to the new media

    . it works. sort of... to make the program interesting, i'm allowing the user to rotate, scale and move the pieces.

    . to scale the pieces - i first set 'ctrl_layer_scale_factorUniform' to 4. then, the module changes 'ctrl_layer_scale_uniform' to change the size

    . and this causes some interesting behaviour

    . here is a screen cap of before i capture the preview and save it as a .png

    Image

    . looks good, so i call my routine above, it saves it into the next layer and shows me the exact same image, in the same location.

    Image

    . this is video image on layer 3 (scale_uniformFactor=4), still image i just captured on layer4 (scale_uniformFacor=2)

    . the capture appears to be smaller....

    . and continual saving of the image w/o moving the top layer produces a getting smaller effect

    Image

    . is this expected behaviour ? or is modul8 not taking into account a layer might be zoomed when it captures the preview?

    -james
    (a nomad. )[
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    by anomad » Sun Jul 11, 2010 4:46 am

    . hmmm. if i set the ctrl_layer_scale_factorUniform equal to 2 on both layers, set the preview to 4:3, limit screen cape size to 1024x768 and go full screen @ 1024x768 and do the screen caps, they only shrink by a couple pixels each time.

    -james
    (a nomad. )

Who is online

Users browsing this forum: No registered users and 34 guests