Android:JavaCv从摄像头获取IplImage 受保护的IplImage进程映像(字节[]数据,整数宽度,整数高度){ int f=4;//子采样系数; //首先,对图像进行降采样并将其转换为灰度图像 IplImage grayImage=IplImage.create(宽度/f、高度/f、IPL\U深度/U 8U,1); int imageWidth=grayImage.width(); int-imageHeight=grayImage.height(); int dataStride=f*宽度; int-imageStride=grayImage.widthStep(); ByteBuffer imageBuffer=灰度图像。getByteBuffer(); 对于(int y=0;y

Android:JavaCv从摄像头获取IplImage 受保护的IplImage进程映像(字节[]数据,整数宽度,整数高度){ int f=4;//子采样系数; //首先,对图像进行降采样并将其转换为灰度图像 IplImage grayImage=IplImage.create(宽度/f、高度/f、IPL\U深度/U 8U,1); int imageWidth=grayImage.width(); int-imageHeight=grayImage.height(); int dataStride=f*宽度; int-imageStride=grayImage.widthStep(); ByteBuffer imageBuffer=灰度图像。getByteBuffer(); 对于(int y=0;y,android,opencv,javacv,Android,Opencv,Javacv,我应该从onPreviewFrame(字节[]数据,摄像头)获取IplImage。 按照我在上面写的方式,我得到的图像比原来的图像小得多。 有没有办法在新的iplimage上保持相同的维度?我能避免使用二次抽样因子吗?我该怎么做呢?是的,只要把setf=1放进去,它就不会再做子样本了。你说得对,我很蠢!:)我不知道为什么,但之前我有4次复制的图像,如果我没有子样本。。。但现在起作用了!谢谢 protected IplImage processImage(byte[] data, int widt

我应该从onPreviewFrame(字节[]数据,摄像头)获取IplImage。 按照我在上面写的方式,我得到的图像比原来的图像小得多。
有没有办法在新的iplimage上保持相同的维度?我能避免使用二次抽样因子吗?我该怎么做呢?

是的,只要把set
f=1
放进去,它就不会再做子样本了。

你说得对,我很蠢!:)我不知道为什么,但之前我有4次复制的图像,如果我没有子样本。。。但现在起作用了!谢谢
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;
}