本讲是android camera专题系列的第19讲,我们介绍android camera2 api专题的实战_app如何实现zsl功能。
更多资源:
资源 | 描述 |
---|---|
在线课程 | |
知识星球 | 星球名称:深入浅出android camera 星球id: 17296815 |
极客笔记圈 |
reprocessable architecture
reprocessable flow
geekcamera2 zsl
判断是否支持reprocess
mstaticmetadata = new staticmetadata(manager.getcameracharacteristics(cameraids));
misreprocesablesupport =
mstaticmetadata.iscapabilitysupported(
cameracharacteristics.request_available_capabilities_yuv_reprocessing) ||
mstaticmetadata.iscapabilitysupported(
cameracharacteristics.request_available_capabilities_private_reprocessing);
获取input size和format
private void setupinputsizeandformat() {
if (misreprocesablesupport) {
mmaxinputstreams =
mstaticmetadata.getvaluefromkeynonnull(cameracharacteristics.request_max_num_input_streams);
}
if (mydebug.log) {
log.i(tag, "[zsl] max supported input streams:" mmaxinputstreams
",misreprocesablesupport:" misreprocesablesupport
",menablereprocessable:" menablereprocessable);
}
try {
if (menablereprocessable && misreprocesablesupport) {
if (isopaquereprocesssupported(cameraids)) {
minputformat = imageformat.private;
minputsize = getmaxsize(minputformat, staticmetadata.streamdirection.input);
log.i(tag, "[zsl] choose private reprocess.");
return;
}
if (isyuvreprocesssupported(cameraids)) {
minputformat = imageformat.yuv_420_888;
minputsize = getmaxsize(minputformat, staticmetadata.streamdirection.input);
log.i(tag, "[zsl] choose yuv reprocess.");
return;
}
}
} catch (exception e) {
}
if (mydebug.log) {
log.i(tag, "reprocess not enabled.");
}
}
创建inputconfiguration
if (menablereprocessable && mmaxinputstreams > 0 && misreprocesablesupport) {
log.i(tag, "[zsl] new inputconfiguration.");
inputconfiguration = new inputconfiguration(minputsize.getwidth(),
minputsize.getheight(),
minputformat);
}
获取reprocess capturerequest
if (menablereprocessable && mmaxinputstreams > 0 && misreprocesablesupport) {
try {
log.i(tag, "[zsl] createreprocesscapturerequest begin");
image inputimage = minputimagereaderlistener.getimage(3000);
log.i(tag, "[zsl] createreprocesscapturerequest");
stillbuilder = mcameradevice.createreprocesscapturerequest(
mzslresultlistener.getcaptureresult(3000, inputimage.gettimestamp()));
log.i(tag, "[zsl] image writer queueinputimage, timestamp:" inputimage.gettimestamp());
minputimagewriter.queueinputimage(inputimage);
inputimage.close();
log.i(tag, "[zsl] createreprocesscapturerequest end");
} catch (exception e) {
log.e(tag, "createreprocesscapturerequest failed:" e.tostring());
}
}