23 #include <visiontransfer/deviceenumeration.h> 24 #include <visiontransfer/asynctransfer.h> 25 #include <visiontransfer/imageset.h> 41 #define snprintf _snprintf_s 47 static const int numImages = 10;
49 static const int imageWidth = 640;
50 static const int imageHeight = 480;
52 int receivedFrames = 0;
69 const int extraBufferSpace = 16;
70 static std::vector<unsigned char> pixelData(imageSet.
getRowStride(0) * imageSet.
getHeight() + extraBufferSpace);
74 for(
int i=0; i<numImages; i++) {
75 while(i-2 >= receivedFrames) {
84 for(
int y=0; y<imageSet.
getHeight(); y++) {
86 pixelData[y*imageSet.
getRowStride(0) + x] = (y + x + i) & 0xff;
91 std::cout <<
"Sending image set " << i << std::endl;
94 }
catch(
const std::exception& ex) {
95 std::cerr <<
"Exception occurred: " << ex.what() << std::endl;
100 for(
int i=0; i<numImages; i++) {
101 std::cout <<
"Receiving image set " << i << std::endl;
113 for(
int imageNumber = 0; imageNumber < imageSet.
getNumberOfImages(); imageNumber++) {
116 snprintf(fileName,
sizeof(fileName),
"image%03d_%d.pgm", imageNumber, i);
127 if(devices.size() == 0) {
128 std::cout <<
"No devices discovered!" << std::endl;
136 std::thread sndThread(sendThread, &asyncTransfer);
137 std::thread rcvThread(receiveThread, &asyncTransfer);
141 }
catch(
const std::exception& ex) {
142 std::cerr <<
"Exception occurred: " << ex.what() << std::endl;
void setNumberOfImages(int number)
Sets the number of valid images in this set.
int getRowStride(int imageNumber) const
Returns the row stride for the pixel data of one image.
void setPixelData(int imageNumber, unsigned char *pixelData)
Sets the pixel data for the given image.
DeviceList discoverDevices()
Discovers new devices and returns the list of all devices that have been found.
void setWidth(int w)
Sets a new width for both images.
void writePgmFile(int imageNumber, const char *fileName) const
Writes one image of the set to a PGM or PPM file.
int getNumberOfImages() const
Returns the number of images in this set.
int getHeight() const
Returns the height of each image.
void setHeight(int h)
Sets a new width for both images.
int getBytesPerPixel(int imageNumber) const
Returns the number of bytes that are required to store one image pixel.
void setPixelFormat(int imageNumber, ImageFormat format)
Sets the pixel format for the given image.
void setRowStride(int imageNumber, int stride)
Sets a new row stride for the pixel data of one image.
ImageFormat
Image formats that can be transferred.
A set of one to three images, but usually two (the left camera image and the disparity map)...
Class for asynchronous transfer of image sets.
Allows for the discovery of devices in the network.
void setIndexOf(ImageType what, int idx)
Assign an image index to a specified ImageType, -1 to disable.
int getWidth() const
Returns the width of each image.
bool collectReceivedImageSet(ImageSet &imageSet, double timeout=-1)
Collects the asynchronously received image.
void sendImageSetAsync(const ImageSet &imageSet, bool deleteData=false)
Starts an asynchronous transmission of the given image set.