Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Trigger camera recording

edited May 2013 in OpenSesame

Hi,

I'd like to trigger camera recording in the middle of experiment, which could record the facial expression of the participants with built-in cameras. Unfortunately I only found audio input plug-in under the external devices. Is there a simple way that I can trigger the video recording?

What I've found is a software Ispy, which allows command line acess:
http://www.ispyconnect.com/userguide-commandline.aspx
I'm wondering whether I could send command using the python inline code, if there is no other way triggering the camera? I know very little about python und have no programming experience :(

Thanks in advance!

Ying

Comments

  • edited 1:53PM

    Hi Ying,

    Recording video

    There are many ways to record video in Python, but it's always a little complicated. You can take a look at OpenCV. That's probably the best Python module for this kind of thing:

    I'm wondering whether I could send command using the python inline code, if there is no other way triggering the camera?

    In principle, yes: You can execute external commands using the Python subprocess module:

    I know very little about python und have no programming experience

    I'm afraid you will have to do a little coding here!

    An easy workaround

    If all of the above sounds to complicated, you could also consider simply recording the participant's faces with a standalone camera. You could have the experiment play a beep at the start of each trial, and feed this into the audio input of the camera, so that you have triggers to time-lock your analysis afterwards. Would that be an idea?

    Good luck!

    Cheers,
    Sebastiaan

  • edited July 2013

    Hello Sebastian,

    I've tried to do some coding to start video recording with OpenCV and the module Videocapture. I installed the python 2.7 and the python extension VideoCapture from http://videocapture.sourceforge.net/, as well as PIL1.1.7 and OpenCV 2.4.6.0. I wrote the following script in the python IDLE to test wether it works:
    image

    It did work well with python, which was pretty encouraging for the beginner like me. So I created a new experiment and simply copied the code to the OpenSesame Inline_script. It came out with an error message:
    image

    I didn't know how to install the VideoCapture into OpenSesame. So I copied the VideoCapture.py and vidcap.pyd to libopensesame like below and ran the experiment again.
    image

    Another error message showed up:
    image

    I could not understand the error. And I also made a compiled file of VideoCapture in the libopensesame to see if it worked better. Unluckily the result is depressing. Do you have an idea why this happened? And could you give me more suggestions how the modules like VideoCapture can be added to the OpenSesame and be used?

    Thank you as always!

    Ying

  • edited 1:53PM

    Hi Ying,

    Well, you're almost there! Essentially, the font files need to be copied as well, which are the .png and .pil files located with VideoCapture.py in the VideoCapture download. Also, I would place the files directly in the OpenSesame folder, and not in the libopensesame subfolder.

    Alternatively, you could consider running OpenSesame from source, seeing as how you have already set up a Python environment:

    Good luck!

    Cheers,
    Sebastiaan

  • edited July 2013

    Hi Sebastiaan,

    it is indeed the problem with the .png and .pil files. It works good after copying. Thanks very very much for the tips.O:-)

    Now I've written a code with the help of the example 'exa3_observer.py' in the VideoCapture example files. There seems to be no example for video recording, but only capturing images. Is video recording achievable with VideoCapture?

    Anyway, I had following codes, which takes 30 pics per second. It worked well, but I am still wondering, whether this is the only way?? to make a video-like series of pictures, which need to be edited afterwards??

    from VideoCapture import Device
    import time, string
    
    ## Specify the amount of seconds to wait between individual captures.
    interval = 1.0 / 30
    vpnr = 5; ##No. of participant
    cam = Device()
    ## If you get horizontal stripes or other errors in the captured picture
    ## (especially at high resolutions), try setting showVideoWindow=0.
    #cam = Device(devnum=0, showVideoWindow=1)
    #cam = Device(devnum=1, showVideoWindow=1)
    
    ## Using the separate programs "setPropertiesDev0/1.pyw" before capturing
    ## works better for some devices.
    ## On the other hand, some devices don't remember their state, so the
    ## properties have to be set at every program start.
    #cam.displayCapturePinProperties()
    #cam.displayCaptureFilterProperties()
    
    print "press 'ctrl + c' to terminate"
    
    i = 0
    quant = interval * .1
    starttime = time.time()
    while i < 120:
        lasttime = now = int((time.time() - starttime) / interval)
        print i
        # FOLDER MUST EXIST
        cam.saveSnapshot('E:\Ying\\vp_' + str(vpnr) + '\\' + string.zfill(str(i), 4) + '.jpg', timestamp=3, boldfont=1)
        i += 1
        while now == lasttime:
            now = float((time.time() - starttime) / interval)
            time.sleep(quant)
    

    Another question is, how can I make the code running aside, while a film is played. (I want to record the facial expression when people watch film clips.) That is to say how to achieve the multi-tasking? As I imagined, there is a code, which triggers the camera and the recording is running and after the film there should be a stop-code which ends the recording. The strukture of OpenSesame GUI seems to be that the inline_script and the plug_ins would be executed one by one.

    I'm really appreciated that you are always there for various questions that we laymen have.

    And I wish you a nice evening!

    Ying

  • edited 1:53PM

    Now I've written a code with the help of the example 'exa3_observer.py' in the VideoCapture example files. There seems to be no example for video recording, but only capturing images. Is video recording achievable with VideoCapture?

    Oddly enough, even though the package is called VideoCapture, it seems like you can only capture stills. But capturing a stream of stills and merging these afterwards should work perfectly well though. That's how I generally my optical illusions as well. A good tool to do this is MEncoder.

    Another question is, how can I make the code running aside, while a film is played. (I want to record the facial expression when people watch film clips.) That is to say how to achieve the multi-tasking?

    The easiest way to do this is using the parallel plug-in. You then add two sequences to the parallel item, the first to handle your trial execution, the second to run the VideoCapture script. The parallel plug-in doesn't work very well on some systems, I should add, but if it works well in your case then this would be the way to go.

    As an aside, I noticed that you manually specify the subject number. You could also just say:

    vpnr = self.get('subject_nr'); ##No. of participant
    

    See:

    Cheers!

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games