protected IplImage processImage(byte[] data, int width, int height) {
int f = 4;// SUBSAMPLING_FACTOR;
// First, downsample our image and convert it into a grayscale IplImage
IplImage grayImage = IplImage.create(width / f, height / f, IPL_DEPTH_8U, 1);
int imageWidth = grayImage.width();
int imageHeight = grayImage.height();
int dataStride = f * width;
int imageStride = grayImage.widthStep();
ByteBuffer imageBuffer = grayImage.getByteBuffer();
for (int y = 0; y < imageHeight; y++) {
int dataLine = y * dataStride;
int imageLine = y * imageStride;
for (int x = 0; x < imageWidth; x++) {
imageBuffer.put(imageLine + x, data[dataLine + f * x]);
}
}
return grayImage;
}
I should get an IplImage from onPreviewFrame(byte[] data, Camera camera). In the way i wrote up there i get an iplimage much smaller than the original one. There is any way to keep the same dimension on the new iplimage? Whould i avoid the subsampling factor? how can i do that?
Yes just put set f = 1
and it won't subsample.