第25讲 获取physical camera数据流 -凯发k8旗舰厅

本讲是android camera专题系列的第25讲,我们介绍android camera2 api专题的获取physical camera数据流。

更多资源:

资源 描述
在线课程
知识星球 星球名称:深入浅出android camera
星球id: 17296815
wechat 极客笔记圈

判断是否支持logical multicamera

mislogicalmulticamera = mstaticmetadata.iscapabilitysupported(
        cameracharacteristics.request_available_capabilities_logical_multi_camera);
set physicalcameraids = manager.getcameracharacteristics(cameraids).getphysicalcameraids();

创建physical camera jpeg stream

private void setupphysicalcamerastreamimagereader() {
    if (menablecapturephysicalstream) {
        mphysical0imagereader = imagereader.newinstance(mphysical0jpegsize.getwidth(),
                mphysical0jpegsize.getheight(), imageformat.jpeg, 2);
        mphysical0imagereader.setonimageavailablelistener(
                new onimageavailablelistener(), mcamerabackgroundhandler);
        mphysical1imagereader = imagereader.newinstance(mphysical1jpegsize.getwidth(),
                mphysical1jpegsize.getheight(), imageformat.jpeg, 2);
        mphysical1imagereader.setonimageavailablelistener(
                new onimageavailablelistener(), mcamerabackgroundhandler);
    }
}

创建physical camera capture session

if (menablecapturephysicalstream) {
    outputconfiguration physical0outputconfiguration = new outputconfiguration(mphysical0imagereader.getsurface());
    physical0outputconfiguration.setphysicalcameraid(mphysicalcameraids[0]);
    outputconfigurations.add(physical0outputconfiguration);
    outputconfiguration physical1outputconfiguration = new outputconfiguration(mphysical1imagereader.getsurface());
    physical1outputconfiguration.setphysicalcameraid(mphysicalcameraids[1]);
    outputconfigurations.add(physical1outputconfiguration);
    msessionconfiguration = new sessionconfiguration(
            is_video_high_speed ?
                    sessionconfiguration.session_high_speed : sessionconfiguration.session_regular,
            outputconfigurations,
            new cameratestutils.handlerexecutor(mcamerabackgroundhandler),
            mystatecallback
    );
    if (inputconfiguration != null) {
        msessionconfiguration.setinputconfiguration(inputconfiguration);
    }
    msessionconfiguration.setsessionparameters(mpreviewbuilder.build());
    if (!mcameradevice.issessionconfigurationsupported(msessionconfiguration)) {
        outputconfigurations.remove(physical0outputconfiguration);
        outputconfigurations.remove(physical1outputconfiguration);
        log.i(tag, "physical_camera session configuration not supported!");
        menablecapturephysicalstream = false;
    }
}

读取physical camera captureresult

map physicalcameraresults = result.getphysicalcameraresults();
if (menablecapturephysicalstream &&
        physicalcameraresults.get(mphysicalcameraids[0]) != null &&
        physicalcameraresults.get(mphysicalcameraids[1]) != null) {
    log.i(tag, "physical_camera"   mphysicalcameraids[0]   "'s result timestamp:"  
            physicalcameraresults.get(mphysicalcameraids[0]).get(captureresult.sensor_timestamp));
    log.i(tag, "physical_camera"   mphysicalcameraids[1]   "'s result timestamp:"  
            physicalcameraresults.get(mphysicalcameraids[1]).get(captureresult.sensor_timestamp));
}

camera课程

python教程

java教程

web教程

数据库教程

图形图像教程

办公软件教程

linux教程

计算机教程

大数据教程

开发工具教程

android camera2 api

网站地图