#include "ImagePacket.h" /* * Construct a packet from an OpenCV Mat, and a beginning index. It will take PACKET_SIZE bytes from the start and add * it to its slice */ ImagePacket::ImagePacket(const cv::Mat *image, const int begin) { const uchar *target = &image->data[begin]; // TODO: handle out of index cases, pad with zeroes. probably also instantiate our byte array with zeroes for (int i = 0; i < PACKET_SIZE; i++) { slice[i] = target[begin + i]; } } /* * Construct a packet from a raw array of unsigned chars, and a beginning index. It will take PACKET_SIZE bytes from the * start and add it to its slice. This will be more useful for embedded scenarios where OpenCV will likely not be used. */ ImagePacket::ImagePacket(const uchar *image, const int begin) { const uchar *target = &image[begin]; // TODO: handle out of index cases, pad with zeroes. probably also instantiate our byte array with zeroes for (int i = 0; i < PACKET_SIZE; i++) { slice[i] = target[begin + i]; } } /* * Apply the packet to an OpenCV Mat. */ int ImagePacket::apply(const cv::Mat *image) const { uchar *target = &image->data[begin]; // TODO: handle out of index cases for (int i = 0; i < PACKET_SIZE; i++) { target[begin + i] = slice[i]; } // TODO: return the actual written size of the packet return PACKET_SIZE; }