Exemplo n.º 1
0
    def get_polarity_event(self, packet_header):
        """Get a packet of polarity event.

        # Arguments
            packet_header: `caerEventPacketHeader`<br/>
                the header that represents a event packet

        # Returns
            events: `numpy.ndarray`<br/>
                a 2-D array that has the shape of (N, 4) where N
                is the number of events in the event packet.
                Each row in the array represents a single polarity event.
                The first number is the timestamp.
                The second number is the X position of the event.
                The third number is the Y position of the event.
                The fourth number represents the polarity of the event
                (positive or negative).
            num_events: `int`<br/>
                number of the polarity events available in the packet.
        """
        num_events, polarity = self.get_event_packet(packet_header,
                                                     libcaer.POLARITY_EVENT)

        # TODO: to implement a noise filtering process
        # or reimplement this function into specific classes

        events = libcaer.get_polarity_event(polarity, num_events * 4).reshape(
            num_events, 4)

        return events, num_events
Exemplo n.º 2
0
    def get_polarity_event(self, packet_header):
        """Get a packet of polarity event.

        # Arguments
            packet_header: `caerEventPacketHeader`<br/>
                the header that represents a event packet

        # Returns
            events: `numpy.ndarray`
                a 2-D array that has the shape of (N, 4) where N
                is the number of events in the event packet.
                Each row in the array represents a single polarity event.
                The first number is the timestamp.
                The second number is the X position of the event.
                The third number is the Y position of the event.
                The fourth number represents the polarity of the event
                (positive or negative).
            num_events: `int`
                number of the polarity events available in the packet.
        """
        num_events = libcaer.caerEventPacketHeaderGetEventNumber(packet_header)
        polarity = libcaer.caerPolarityEventPacketFromPacketHeader(
            packet_header)

        events = libcaer.get_polarity_event(polarity, num_events * 4).reshape(
            num_events, 4)

        return events, num_events
Exemplo n.º 3
0
    def get_polarity_event(self, packet_header, noise_filter=False):
        """Get a packet of polarity event.

        # Arguments
            packet_header: `caerEventPacketHeader`<br/>
                the header that represents a event packet
            noise_filter: `bool`<br/>
                the background activity filter is applied if True.

        # Returns
            events: `numpy.ndarray`<br/>
                a 2-D array that has the shape of (N, 4) where N
                is the number of events in the event packet.
                Each row in the array represents a single polarity event.
                The first number is the timestamp.
                The second number is the X position of the event.
                The third number is the Y position of the event.
                The fourth number represents the polarity of the event
                (positive or negative).<br/>
                If the `noise_filter` option is set to `True`,
                this array has an additional column at the end.
                The last column represents the validity of the corresponding
                event. Filtered events will be marked as 0.
            num_events: `int`<br/>
                number of the polarity events available in the packet.

        """
        num_events, polarity = self.get_event_packet(packet_header,
                                                     libcaer.POLARITY_EVENT)

        if noise_filter is True:
            polarity = self.noise_filter.apply(polarity)

            events = libcaer.get_filtered_polarity_event(
                polarity, num_events * 5).reshape(num_events, 5)
        else:
            events = libcaer.get_polarity_event(polarity,
                                                num_events * 4).reshape(
                                                    num_events, 4)

        return events, num_events