37 #include <Image/ImageProcessor.h>
38 #include <Image/ByteImage.h>
39 #include <Image/FloatImage.h>
41 void visionx::tools::convertImage(
const visionx::ImageFormatInfo& imageFormat,
const visionx::ImageType destinationImageType,
void* inputData,
void* outputData)
43 bool succeeded =
true;
45 visionx::ImageDimension dimension = imageFormat.dimension;
46 visionx::ImageType sourceType = imageFormat.type;
47 visionx::ImageType destinationType = destinationImageType;
50 if (sourceType == destinationType)
52 memcpy(outputData, inputData, imageFormat.bytesPerPixel * imageFormat.dimension.width * imageFormat.dimension.height);
58 sourceImage.pixels = (
unsigned char*) inputData;
61 destinationImage.pixels = (
unsigned char*) outputData;
68 switch (destinationType)
72 CByteImage tempRgbImage(dimension.width, dimension.height, CByteImage::eRGB24);
73 ::ImageProcessor::ConvertBayerPattern(&sourceImage, &tempRgbImage,
tools::convert(imageFormat.bpType));
74 ::ImageProcessor::ConvertImage(&tempRgbImage, &destinationImage);
80 ::ImageProcessor::ConvertBayerPattern(&sourceImage, &destinationImage,
tools::convert(imageFormat.bpType));
101 switch (destinationType)
105 ::ImageProcessor::ConvertImage(&sourceImage, &destinationImage);
126 switch (destinationType)
130 ::ImageProcessor::ConvertImage(&sourceImage, &destinationImage);
173 CByteImage::ImageType type = CByteImage::eGrayScale;
182 type = CByteImage::eRGB24;
191 return new CByteImage(imageFormat.dimension.width, imageFormat.dimension.height, type);
208 int numberOfChannels = 1;
216 case eFloat3Channels:
217 numberOfChannels = 3;
227 return new CFloatImage(imageFormat.dimension.width, imageFormat.dimension.height, numberOfChannels);
239 visionx::MonocularCalibration calibration;
240 calibration.cameraParam.width = 640;
241 calibration.cameraParam.height = 480;
242 calibration.cameraParam.focalLength.resize(2);
243 calibration.cameraParam.focalLength[0] = 500;
244 calibration.cameraParam.focalLength[1] = 500;
245 calibration.cameraParam.principalPoint.resize(2);
246 calibration.cameraParam.principalPoint[0] = calibration.cameraParam.width / 2;
247 calibration.cameraParam.principalPoint[1] = calibration.cameraParam.height / 2;
248 std::vector<std::vector<float> > mat(3);
249 std::vector<float> rowVec(3);
253 calibration.cameraParam.translation = rowVec;
260 calibration.cameraParam.rotation = mat;
262 calibration.cameraParam.distortion = rowVec;