[英]Camera preview image data processing with Android L and Camera2 API
[英]How to android camera2 feed the preview frame data to OpenCV for processing
我想在相機預覽中做一些圖像處理,比如灰度在老相機api很容易,但移植到camera2 api,我不知道怎么做
public void onPreviewFrame(byte[] data, Camera cam) {
// custom image data processing
}
我試圖從這里獲得框架(如問題的答案中所建議的):
private final ImageReader.OnImageAvailableListener mOnImageAvailableListener
= new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
Log.d("Img", "onImageAvailable");
mBackgroundHandler.post(new ImageSaver(reader.acquireNextImage(), mFile));
}
};
他沒用,因為只有在用戶執行圖像捕獲后才會調用回調
來自Google https://github.com/googlesamples/android-HdrViewfinder的此示例提供了您需要執行的操作的基本信息。
摘要:
1)將Surface添加到攝像機的輸出
2)收聽此表面的更新,在上面的示例中,它發生在ViewfinderProcessor.java中
上面的示例使用2個曲面進行假HDR預覽,但您應該能夠輕松地將示例清理為僅使用1個曲面。 此示例還使用自定義Render Script內核進行處理,您不需要使用它。 您可以輕松捕獲ViewfinderProcessor.java中的緩沖區類型Allocation ,以獲取舊的Camera API中的字節數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.