OpenViBE forum

The OpenViBE community
It is currently Sat Dec 16, 2017 8:33 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Mar 05, 2015 9:35 am 
Offline

Joined: Sun May 04, 2014 12:25 pm
Posts: 1
Hello everybody,

I have written a script in python but for some reason OpenViBE lags when I run the script and I get an output like
Code:
[WARNING] <Player::can not reach realtime> 1 second(s) late...

I thought the problem was an infinite loop or so in my code, so I added debug info but it turns out OV seems to stuck between two OVBox.process() calls.
Here are the relevant parts (I hope!) of my code
Code:
   def process(self):
      print "new process"
      while len(self.input[0]):
         print 'start loop'
         buff = self.input[0].pop()
         if(type(buff) == OVSignalHeader):
            self.signalHeader = buff
            self.init()
            print 'init'
            
         elif(type(buff) == OVSignalBuffer):
            numpyBuffer = np.array(buff).reshape(tuple(self.signalHeader.dimensionSizes))
            signal.extend(numpyBuffer.T)
            prediction = best_cca() # returns either of [7,9,11,13,15,-1]
            self.send_stimulation(prediction, buff)
            print "sent stimulation", prediction
            
         elif(type(buff) == OVSignalEnd):
            outputEnd = OVStimulationEnd(buff.startTime, buff.endTime)
            self.output[0].append(outputEnd)
            print 'end'
      print 'end process'
   
   def init(self):
      ...
      outputHeader = OVStimulationHeader(
      self.signalHeader.startTime,
      self.signalHeader.endTime)
      self.output[0].append(outputHeader)

   def send_stimulation(self, prediction, buff):
      if prediction > 0: stim = OpenViBE_stimulation['OVTK_StimulationId_LabelStart'] + prediction
      else: stim = OpenViBE_stimulation['OVTK_StimulationId_NonTarget']
      stimSet = OVStimulationSet(buff.startTime, buff.endTime)
      stimSet.append(OVStimulation(stim, buff.endTime, 0.))
      self.output[0].append(stimSet)

with an output like
Code:
new process
end process
...
new process
start loop
sent stimulation 7
end process
[WARNING] <Player::can not reach realtime> 1 second(s) late...

This doesn't happen systematicly, but every five predictions or so... Does anybody know what mistake I have made?


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 09, 2015 8:29 am 
Offline

Joined: Tue Dec 04, 2012 3:53 pm
Posts: 601
Location: INRIA Rennes, FRANCE
Hi Oettam,

one suspicious thing I see is that you're calling init from process(). This likely shouldn't be done.

To debug this, what I'd do is that I'd take the hello world example script

Code:
class MyOVBox(OVBox):
        def __init__(self):
                OVBox.__init__(self)

        def initialize(self):
                # nop
                return

        def process(self):
                # print something
                print("hello")

        def uninitialize(self):
                # nop
                return

box = MyOVBox()


and check that it runs properly. Then, line by line, start modifying it towards your script and see where the problem appears for the first time.


Happy hacking,
Jussi


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Americanized by Maƫl Soucaze.