Example #1
0
    def grab_next_frame_blocking(self):
        curmsg = self._get_network_buf()
        self.last_timestamp = curmsg.timestamp
        self.last_framenumber = curmsg.framenumber

        outbuf = _cam_iface_shm.get_data_copy(curmsg)
        return outbuf
Example #2
0
    def grab_next_frame_into_buf_blocking(self, outbuf, bypass_buffer_checks=False):
        """grab frame into user-supplied buffer"""
        # XXX this method isn't done yet...

        # XXX change to read data out of shared memory as quickly as
        # possible (no self.savemsg)

        if self.savebuf is not None:

            # print 'ADS 1'
            if self.save_framenumber == self.next_framenumber:
                # print 'ADS 1.1'
                self.last_timestamp = self.save_timestamp
                self.last_framenumber = self.save_framenumber
                self.next_framenumber = self.save_framenumber + 1
                outbuf = self.savebuf
                self.savebuf = None
            else:
                # print 'ADS 1.2'
                assert self.save_framenumber > self.next_framenumber
                self.next_framenumber += 1
                raise FrameDataMissing("missing data")
        else:
            # print 'ADS 2'
            curmsg = self._get_network_buf()
            cur_timestamp = curmsg.timestamp
            cur_framenumber = curmsg.framenumber
            # print 'cur_framenumber',cur_framenumber
            curbuf = _cam_iface_shm.get_data_copy(curmsg, optional_preallocated_buf=outbuf)

            if self.last_framenumber is None:
                # print 'ADS 2.1'
                # first frame
                self.last_timestamp = cur_timestamp
                self.last_framenumber = cur_framenumber
                self.next_framenumber = cur_framenumber + 1
                outbuf = curbuf
            else:
                # print 'ADS 2.2'
                if self.next_framenumber == cur_framenumber:
                    # print 'ADS 2.3'
                    # no frames skipped
                    self.last_timestamp = cur_timestamp
                    self.last_framenumber = cur_framenumber
                    self.next_framenumber = cur_framenumber + 1
                    outbuf = curbuf
                else:
                    # print 'ADS 2.4'
                    assert cur_framenumber > self.next_framenumber
                    self.savebuf = curbuf
                    self.save_framenumber = cur_framenumber
                    self.save_timestamp = cur_timestamp
                    self.next_framenumber += 1
                    raise FrameDataMissing("missing data")
        return outbuf