1

我想在以下程序中使用预制文件而不是实时捕获来跟踪此人。

  1. 什么是 realsense SDK API 用于加载预制文件并逐帧捕捉?

  2. 是否可以使用任何其他相机捕获的任何一般视频/图像文件来检测/跟踪人员?

示例程序:

示例源链接

资源

    #include <thread>
#include <iostream>
#include <signal.h>
#include "version.h"
#include "pt_utils.hpp"
#include "pt_console_display.hpp"
#include "pt_web_display.hpp"
#include "or_console_display.hpp"
#include "or_web_display.hpp"

using namespace std;
using namespace rs::core;
using namespace rs::object_recognition;

// Version number of the samples
extern constexpr auto rs_sample_version = concat("VERSION: ",RS_SAMPLE_VERSION_STR);

// Doing the OR processing for a frame can take longer than the frame interval, so we
// keep track of whether or not we are still processing the last frame.
bool is_or_processing_frame = false;
unique_ptr<web_display::pt_web_display> pt_web_view;
unique_ptr<web_display::or_web_display> or_web_view;

unique_ptr<console_display::pt_console_display> pt_console_view;
unique_ptr<console_display::or_console_display> or_console_view;

void processing_OR(correlated_sample_set or_sample_set, or_video_module_impl* impl, or_data_interface* or_data,
                   or_configuration_interface* or_configuration)
{
    rs::core::status st;

    // Declare data structure and size for results
    rs::object_recognition::localization_data* localization_data = nullptr;

    //Run object localization processing
    st = impl->process_sample_set(or_sample_set);
    if (st != rs::core::status_no_error)
    {
        is_or_processing_frame = false;
        return;
    }

    // Retrieve recognition data from the or_data object
    int array_size = 0;
    st = or_data->query_localization_result(&localization_data, array_size);
    if (st != rs::core::status_no_error)
    {
        is_or_processing_frame = false;
        return;
    }

    //Send OR data to ui
    if (localization_data && array_size != 0)
    {
        or_console_view->on_object_localization_data(localization_data, array_size, or_configuration);
        or_web_view->on_object_localization_data(localization_data, array_size, or_configuration);
    }

    is_or_processing_frame = false;
}

int main(int argc,char* argv[])
{
    rs::core::status st;
    pt_utils pt_utils;

    rs::core::image_info colorInfo,depthInfo;
    rs::core::video_module_interface::actual_module_config actualModuleConfig;
    rs::person_tracking::person_tracking_video_module_interface* ptModule = nullptr;
    rs::object_recognition::or_video_module_impl impl;
    rs::object_recognition::or_data_interface* or_data = nullptr;
    rs::object_recognition::or_configuration_interface* or_configuration = nullptr;

    cout << endl << "Initializing Camera, Object Recognition and Person Tracking modules" << endl;
    if(pt_utils.init_camera(colorInfo,depthInfo,actualModuleConfig,impl,&or_data,&or_configuration) != rs::core::status_no_error)
    {
        cerr << "Error: Device is null." << endl << "Please connect a RealSense device and restart the application" << endl;
        return -1;
    }
    pt_utils.init_person_tracking(&ptModule);

    //Person Tracking Configuration. Set tracking mode to 0
    ptModule->QueryConfiguration()->QueryTracking()->Enable();
    ptModule->QueryConfiguration()->QueryTracking()->SetTrackingMode((Intel::RealSense::PersonTracking::PersonTrackingConfiguration::TrackingConfiguration::TrackingMode)0);
    if(ptModule->set_module_config(actualModuleConfig) != rs::core::status_no_error)
    {
        cerr<<"error : failed to set the enabled module configuration" << endl;
        return -1;
    }

    //Object Recognition Configuration
    //Set mode to localization
    or_configuration->set_recognition_mode(rs::object_recognition::recognition_mode::LOCALIZATION);
    //Set the localization mechnizm to use CNN
    or_configuration->set_localization_mechanism(rs::object_recognition::localization_mechanism::CNN);
    //Ignore all objects under 0.7 probabilty (confidence)
    or_configuration->set_recognition_confidence(0.7);
    //Enabling object center feature
    or_configuration->enable_object_center_estimation(true);

    st = or_configuration->apply_changes();
    if (st != rs::core::status_no_error)
        return st;

    //Launch GUI
    string sample_name = argv[0];
    // Create console view
    pt_console_view = move(console_display::make_console_pt_display());
    or_console_view = move(console_display::make_console_or_display());
    // Create and start remote(Web) view
    or_web_view = move(web_display::make_or_web_display(sample_name, 8000, true));
    pt_web_view = move(web_display::make_pt_web_display(sample_name, 8000, true));


    cout << endl << "-------- Press Esc key to exit --------" << endl << endl;

    while (!pt_utils.user_request_exit())
    {
        //Get next frame
        rs::core::correlated_sample_set* sample_set = pt_utils.get_sample_set(colorInfo,depthInfo);
        rs::core::correlated_sample_set* sample_set_pt = pt_utils.get_sample_set(colorInfo,depthInfo);

        //Increment reference count of images at sample set
        for (int i = 0; i < static_cast<uint8_t>(rs::core::stream_type::max); ++i)
        {
            if (sample_set_pt->images[i] != nullptr)
            {
                sample_set_pt->images[i]->add_ref();
            }
        }

        //Draw Color frames
        auto colorImage = (*sample_set)[rs::core::stream_type::color];
        pt_web_view->on_rgb_frame(10, colorImage->query_info().width, colorImage->query_info().height, colorImage->query_data());

        //Run OR in a separate thread. Update GUI with the result
        if (!is_or_processing_frame)         // If we aren't already processing or for a frame:
        {
            is_or_processing_frame = true;
            std::thread recognition_thread(processing_OR, *sample_set,
                                           &impl, or_data, or_configuration);
            recognition_thread.detach();
        }

        //Run Person Tracking
        if (ptModule->process_sample_set(*sample_set_pt) != rs::core::status_no_error)
        {
            cerr << "error : failed to process sample" << endl;
            continue;
        }

        //Update GUI with PT result
        pt_console_view->on_person_info_update(ptModule);
        pt_web_view->on_PT_tracking_update(ptModule);

    }

    pt_utils.stop_camera();
    actualModuleConfig.projection->release();

    return 0;
}
4

1 回答 1

0
  1. 安装 Realsense SKD 后,查看 realsense_playback_device_sample 以了解如何加载 RSSDK 捕获文件。
  2. 简短的回答不是真的。除了从其他相机捕获的图像外,您还需要提供相机的内在和外在设置,以便计算物体的深度并调用人员跟踪模块。
于 2018-01-21T14:10:06.290 回答