コード例 #1
0
ファイル: pipe_manager.cpp プロジェクト: ximenjx/libxcam
XCamReturn
PipeManager::start ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    if (_smart_analyzer.ptr ()) {
        if (_smart_analyzer->prepare_handlers () != XCAM_RETURN_NO_ERROR) {
            XCAM_LOG_INFO ("prepare smart analyzer handler failed");
        }

        _smart_analyzer->set_results_callback (this);
        if (_smart_analyzer->init (1920, 1080, 25) != XCAM_RETURN_NO_ERROR) {
            XCAM_LOG_INFO ("initialize smart analyzer failed");
        }
        if (_smart_analyzer->start () != XCAM_RETURN_NO_ERROR) {
            XCAM_LOG_INFO ("start smart analyzer failed");
        }
    }

    if (!_processor_center->has_processors ()) {
        XCAM_LOG_ERROR ("image processors empty");
    }
    _processor_center->set_image_callback (this);
    XCAM_FAILED_STOP (ret = _processor_center->start (), "3A process center start failed");

    _is_running = true;

    XCAM_LOG_DEBUG ("pipe manager started");
    return XCAM_RETURN_NO_ERROR;
}
コード例 #2
0
ファイル: device_manager.cpp プロジェクト: skibey/libxcam
XCamReturn
DeviceManager::start ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    // start device
    XCAM_ASSERT (_device->is_opened());
    if (!_device.ptr() || !_device->is_opened()) {
        XCAM_FAILED_STOP (ret = XCAM_RETURN_ERROR_FILE, "capture device not ready");
    }
    XCAM_FAILED_STOP (ret = _device->start(), "capture device start failed");

    //start subdevice
    //XCAM_ASSERT (_subdevice->is_opened());
    if (_subdevice.ptr()) {
        if (!_subdevice->is_opened())
            XCAM_FAILED_STOP (ret = XCAM_RETURN_ERROR_FILE, "event device not ready");
        XCAM_FAILED_STOP (ret = _subdevice->start(), "start event device failed");
    }

    //suppose _device and _subdevice already started
    if (!_isp_controller.ptr ())
        _isp_controller = new IspController (_device);
    XCAM_ASSERT (_isp_controller.ptr());

    if (_has_3a) {
        // Initialize and start analyzer
        uint32_t width = 0, height = 0;
        uint32_t fps_n = 0, fps_d = 0;
        double framerate = 30.0;

        if (!_3a_analyzer.ptr()) {
            _3a_analyzer = X3aAnalyzerManager::instance()->create_analyzer();
            if (!_3a_analyzer.ptr()) {
                XCAM_FAILED_STOP (ret = XCAM_RETURN_ERROR_PARAM, "create analyzer failed");
            }
        }
        if (_3a_analyzer->prepare_handlers () != XCAM_RETURN_NO_ERROR) {
            XCAM_FAILED_STOP (ret = XCAM_RETURN_ERROR_PARAM, "prepare analyzer handler failed");
        }
        _3a_analyzer->set_results_callback (this);

        _device->get_size (width, height);
        _device->get_framerate (fps_n, fps_d);
        if (fps_d)
            framerate = (double)fps_n / (double)fps_d;
        XCAM_FAILED_STOP (
            ret = _3a_analyzer->init (width, height, framerate),
            "initialize analyzer failed");

        XCAM_FAILED_STOP (ret = _3a_analyzer->start (), "start analyzer failed");

        if (_smart_analyzer.ptr()) {
            if (_smart_analyzer->prepare_handlers () != XCAM_RETURN_NO_ERROR) {
                XCAM_LOG_INFO ("prepare smart analyzer handler failed");
            }
            //_smart_analyzer->set_results_callback (this);
            if (_smart_analyzer->init (width, height, framerate) != XCAM_RETURN_NO_ERROR) {
                XCAM_LOG_INFO ("initialize smart analyzer failed");
            }
            if (_smart_analyzer->start () != XCAM_RETURN_NO_ERROR) {
                XCAM_LOG_INFO ("start smart analyzer failed");
            }
        }

        // Initialize and start image processors
        if (!_3a_process_center->has_processors()) {
            // default processor
            SmartPtr<ImageProcessor> default_processor = new IspImageProcessor (_isp_controller);
            XCAM_ASSERT (default_processor.ptr ());
            _3a_process_center->insert_processor (default_processor);
        }

        _3a_process_center->set_image_callback(this);
        XCAM_FAILED_STOP (ret = _3a_process_center->start (), "3A process center start failed");

    }

    //Initialize and start poll thread
    _poll_thread = new PollThread;
    _poll_thread->set_capture_device (_device);
    if (_subdevice.ptr ())
        _poll_thread->set_event_device (_subdevice);
    _poll_thread->set_isp_controller (_isp_controller);
    _poll_thread->set_poll_callback (this);
    _poll_thread->set_stats_callback (this);

    XCAM_FAILED_STOP (ret = _poll_thread->start(), "start poll failed");

    _is_running = true;

    XCAM_LOG_DEBUG ("Device manager started");
    return XCAM_RETURN_NO_ERROR;
}