Example #1
0
    def __new__(cls, camera, frame): 
        """
        Convert a dc1394 frame into an Frame instance.
        """
        dtyp = ARRAY(c_byte, frame.contents.image_bytes)
        buf = dtyp.from_address(frame.contents.image)
        width, height = frame.contents.size
        pixels = width*height
        endianess = frame.contents.little_endian and "<" or ">"
        typ_string = "%su%i" % (endianess,
                frame.contents.image_bytes/pixels)

        img = ndarray.__new__(cls, shape=(height, width),
                dtype=typ_string, buffer=buf)

        img.frame_id = frame.contents.id
        img.frames_behind = frame.contents.frames_behind
        img.position = frame.contents.position
        img.packet_size = frame.contents.packet_size
        img.packets_per_frame = frame.contents.packets_per_frame
        img.timestamp = frame.contents.timestamp
        img.video_mode = video_mode_vals[frame.contents.video_mode]
        img.data_depth = frame.contents.data_depth
        img.color_coding = color_coding_vals[frame.contents.color_coding]
        img.color_filter = frame.contents.color_filter
        img.yuv_byte_order = frame.contents.yuv_byte_order
        img.stride = frame.contents.stride
        # save camera and frame for enqueue()
        img._frame = frame
        img._cam = camera
        return img
Example #2
0
    def __new__(cls, camera, frame):
        """
        Convert a phloxar-dc1394 frame into a Frame instance.
        :param camera:
        :param frame:
        :return:
        """
        dtype = ARRAY(c_byte, frame.contents.image_bytes)
        buf = dtype.from_address(frame.contents.image)
        width, height = frame.contents.size
        pixels = width * height
        endian = frame.contents.little_endian and '<' or '>'
        type_str = '%su%i' % (endian, frame.contents.image_bytes / pixels)
        img = ndarray.__new__(cls, shape=(height, width), dtype=type_str, buffer=buf)

        img.frame_id = frame.contents.id
        img.frames_behind = frame.contents.frames_behind
        img.position = frame.contents.position
        img.packet_size = frame.contents.packet_size
        img.packets_per_frame = frame.contents.packet_per_frame
        img.timestamp = frame.contents.timestamp
        img.video_mode = video_modes[frame.contents.video_mode]
        img.data_depth = frame.contents.data_depth
        img.color_coding = color_codings[frame.contents.color_coding]
        img.color_filter = frame.contents.color_filter
        img.yuv_byte_order = frame.contents.yuv_byte_order
        img.stride = frame.contents.stride
        # save camera and frame for enqueue()
        img._frame = frame
        img._cam = camera

        return img
Example #3
0
    def __new__(cls, camera, frame):
        """
        Convert a phloxar-dc1394 frame into a Frame instance.
        :param camera:
        :param frame:
        :return:
        """
        dtype = ARRAY(c_byte, frame.contents.image_bytes)
        buf = dtype.from_address(frame.contents.image)
        width, height = frame.contents.size
        pixels = width * height
        endian = frame.contents.little_endian and '<' or '>'
        type_str = '%su%i' % (endian, frame.contents.image_bytes / pixels)
        img = ndarray.__new__(cls,
                              shape=(height, width),
                              dtype=type_str,
                              buffer=buf)

        img.frame_id = frame.contents.id
        img.frames_behind = frame.contents.frames_behind
        img.position = frame.contents.position
        img.packet_size = frame.contents.packet_size
        img.packets_per_frame = frame.contents.packet_per_frame
        img.timestamp = frame.contents.timestamp
        img.video_mode = video_modes[frame.contents.video_mode]
        img.data_depth = frame.contents.data_depth
        img.color_coding = color_codings[frame.contents.color_coding]
        img.color_filter = frame.contents.color_filter
        img.yuv_byte_order = frame.contents.yuv_byte_order
        img.stride = frame.contents.stride
        # save camera and frame for enqueue()
        img._frame = frame
        img._cam = camera

        return img
Example #4
0
    def __new__(cls, camera, frame):
        """
        Convert a dc1394 frame into an Frame instance.
        """
        dtyp = ARRAY(c_byte, frame.contents.image_bytes)
        buf = dtyp.from_address(frame.contents.image)
        width, height = frame.contents.size
        pixels = width * height
        endianess = frame.contents.little_endian and "<" or ">"
        typ_string = "%su%i" % (endianess, frame.contents.image_bytes / pixels)

        img = ndarray.__new__(cls,
                              shape=(height, width),
                              dtype=typ_string,
                              buffer=buf)

        img.frame_id = frame.contents.id
        img.frames_behind = frame.contents.frames_behind
        img.position = frame.contents.position
        img.packet_size = frame.contents.packet_size
        img.packets_per_frame = frame.contents.packets_per_frame
        img.timestamp = frame.contents.timestamp
        img.video_mode = video_mode_vals[frame.contents.video_mode]
        img.data_depth = frame.contents.data_depth
        img.color_coding = color_coding_vals[frame.contents.color_coding]
        img.color_filter = frame.contents.color_filter
        img.yuv_byte_order = frame.contents.yuv_byte_order
        img.stride = frame.contents.stride
        # save camera and frame for enqueue()
        img._frame = frame
        img._cam = camera
        return img