Lor*_*uto 2 android opencv javacv
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;
}
Run Code Online (Sandbox Code Playgroud)
我应该从onPreviewFrame(byte []数据,相机相机)获得一个IplImage.在我写的那种方式中,我得到的iplimage比原来的小得多.有没有办法在新的iplimage上保持相同的维度?我应该避免使用子采样因子吗?我怎样才能做到这一点?
| 归档时间: |
|
| 查看次数: |
2040 次 |
| 最近记录: |