国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Azure Kinect獲取相機內參

這篇具有很好參考價值的文章主要介紹了Azure Kinect獲取相機內參。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

在采集點云數(shù)據(jù)時需要根據(jù)相機不同depth、color分辨率調整對應相機內參u0(px)、v0(py)、fx、fy,那么具體內參怎么獲得呢?就跟隨ludaner一起來看看吧。

其實Azure-Kinect-Sensor-SDK已經(jīng)提供了example代碼,只需編譯運行即可:Azure-Kinect-Sensor-SDK/main.cpp at develop · microsoft/Azure-Kinect-Sensor-SDK · GitHubA cross platform (Linux and Windows) user mode SDK to read data from your Azure Kinect device. - Azure-Kinect-Sensor-SDK/main.cpp at develop · microsoft/Azure-Kinect-Sensor-SDKhttps://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/develop/examples/calibration/main.cpp

順便把main.cpp代碼貼出來

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>
#include <k4a/k4a.h>
using namespace std;

static string get_serial(k4a_device_t device)
{
    size_t serial_number_length = 0;

    if (K4A_BUFFER_RESULT_TOO_SMALL != k4a_device_get_serialnum(device, NULL, &serial_number_length))
    {
        cout << "Failed to get serial number length" << endl;
        k4a_device_close(device);
        exit(-1);
    }

    char *serial_number = new (std::nothrow) char[serial_number_length];
    if (serial_number == NULL)
    {
        cout << "Failed to allocate memory for serial number (" << serial_number_length << " bytes)" << endl;
        k4a_device_close(device);
        exit(-1);
    }

    if (K4A_BUFFER_RESULT_SUCCEEDED != k4a_device_get_serialnum(device, serial_number, &serial_number_length))
    {
        cout << "Failed to get serial number" << endl;
        delete[] serial_number;
        serial_number = NULL;
        k4a_device_close(device);
        exit(-1);
    }

    string s(serial_number);
    delete[] serial_number;
    serial_number = NULL;
    return s;
}

static void print_calibration()
{
    uint32_t device_count = k4a_device_get_installed_count();
    cout << "Found " << device_count << " connected devices:" << endl;
    cout << fixed << setprecision(6);

    for (uint8_t deviceIndex = 0; deviceIndex < device_count; deviceIndex++)
    {
        k4a_device_t device = NULL;
        if (K4A_RESULT_SUCCEEDED != k4a_device_open(deviceIndex, &device))
        {
            cout << deviceIndex << ": Failed to open device" << endl;
            exit(-1);
        }

        k4a_calibration_t calibration;

        k4a_device_configuration_t deviceConfig = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
        deviceConfig.color_format = K4A_IMAGE_FORMAT_COLOR_MJPG;
        deviceConfig.color_resolution = K4A_COLOR_RESOLUTION_1080P;
        deviceConfig.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
        deviceConfig.camera_fps = K4A_FRAMES_PER_SECOND_30;
        deviceConfig.wired_sync_mode = K4A_WIRED_SYNC_MODE_STANDALONE;
        deviceConfig.synchronized_images_only = true;

        // get calibration
        if (K4A_RESULT_SUCCEEDED !=
            k4a_device_get_calibration(device, deviceConfig.depth_mode, deviceConfig.color_resolution, &calibration))
        {
            cout << "Failed to get calibration" << endl;
            exit(-1);
        }

        auto calib = calibration.depth_camera_calibration;

        cout << "\n===== Device " << (int)deviceIndex << ": " << get_serial(device) << " =====\n";
        cout << "resolution width: " << calib.resolution_width << endl;
        cout << "resolution height: " << calib.resolution_height << endl;
        cout << "principal point x: " << calib.intrinsics.parameters.param.cx << endl;
        cout << "principal point y: " << calib.intrinsics.parameters.param.cy << endl;
        cout << "focal length x: " << calib.intrinsics.parameters.param.fx << endl;
        cout << "focal length y: " << calib.intrinsics.parameters.param.fy << endl;
        cout << "radial distortion coefficients:" << endl;
        cout << "k1: " << calib.intrinsics.parameters.param.k1 << endl;
        cout << "k2: " << calib.intrinsics.parameters.param.k2 << endl;
        cout << "k3: " << calib.intrinsics.parameters.param.k3 << endl;
        cout << "k4: " << calib.intrinsics.parameters.param.k4 << endl;
        cout << "k5: " << calib.intrinsics.parameters.param.k5 << endl;
        cout << "k6: " << calib.intrinsics.parameters.param.k6 << endl;
        cout << "center of distortion in Z=1 plane, x: " << calib.intrinsics.parameters.param.codx << endl;
        cout << "center of distortion in Z=1 plane, y: " << calib.intrinsics.parameters.param.cody << endl;
        cout << "tangential distortion coefficient x: " << calib.intrinsics.parameters.param.p1 << endl;
        cout << "tangential distortion coefficient y: " << calib.intrinsics.parameters.param.p2 << endl;
        cout << "metric radius: " << calib.intrinsics.parameters.param.metric_radius << endl;

        k4a_device_close(device);
    }
}

static void calibration_blob(uint8_t deviceIndex = 0, string filename = "calibration.json")
{
    k4a_device_t device = NULL;

    if (K4A_RESULT_SUCCEEDED != k4a_device_open(deviceIndex, &device))
    {
        cout << deviceIndex << ": Failed to open device" << endl;
        exit(-1);
    }

    size_t calibration_size = 0;
    k4a_buffer_result_t buffer_result = k4a_device_get_raw_calibration(device, NULL, &calibration_size);
    if (buffer_result == K4A_BUFFER_RESULT_TOO_SMALL)
    {
        vector<uint8_t> calibration_buffer = vector<uint8_t>(calibration_size);
        buffer_result = k4a_device_get_raw_calibration(device, calibration_buffer.data(), &calibration_size);
        if (buffer_result == K4A_BUFFER_RESULT_SUCCEEDED)
        {
            ofstream file(filename, ofstream::binary);
            file.write(reinterpret_cast<const char *>(&calibration_buffer[0]), (long)calibration_size);
            file.close();
            cout << "Calibration blob for device " << (int)deviceIndex << " (serial no. " << get_serial(device)
                 << ") is saved to " << filename << endl;
        }
        else
        {
            cout << "Failed to get calibration blob" << endl;
            exit(-1);
        }
    }
    else
    {
        cout << "Failed to get calibration blob size" << endl;
        exit(-1);
    }
}

static void print_usage()
{
    cout << "Usage: calibration_info [device_id] [output_file]" << endl;
    cout << "Using calibration_info.exe without any command line arguments will display" << endl
         << "calibration info of all connected devices in stdout. If a device_id is given" << endl
         << "(0 for default device), the calibration.json file of that device will be" << endl
         << "saved to the current directory." << endl;
}

int main(int argc, char **argv)
{
    if (argc == 1)
    {
        print_calibration();
    }
    else if (argc == 2)
    {
        calibration_blob((uint8_t)atoi(argv[1]), "calibration.json");
    }
    else if (argc == 3)
    {
        calibration_blob((uint8_t)atoi(argv[1]), argv[2]);
    }
    else
    {
        print_usage();
    }

    return 0;
}

cmake編譯不通過的添加或修改CMakeLists.txt為

## k4a
find_package(k4a 1.3.0 QUIET)
include_directories(${K4A_INCLUDE_DIRS})

add_executable(calibration_info main.cpp)
target_link_libraries(calibration_info PRIVATE k4a::k4a)

編譯成功運行,可指定直接print輸出或輸出為json文件

修改以下代碼輸出不同分辨率:

deviceConfig.color_resolution = K4A_COLOR_RESOLUTION_1536P;
deviceConfig.depth_mode = K4A_DEPTH_MODE_WFOV_UNBINNED;

Azure Kinect提供的所有分辨率可在以下網(wǎng)頁查看https://docs.microsoft.com/zh-cn/azure/Kinect-dk/hardware-specification

修改以下代碼可選擇輸出color或depth相機分辨率

// color_camera_calibration, depth_camera_calibration
auto calib = calibration.color_camera_calibration; 

運行程序即可,po一個結果

Found 1 connected devices:

===== Device 0:  =====
resolution width: 2048
resolution height: 1536
principal point x: 1023.543701
principal point y: 777.486084
focal length x: 975.207458
focal length y: 974.770630
radial distortion coefficients:
k1: 0.205187
k2: -2.718986
k3: 1.783927
k4: 0.082789
k5: -2.509135
k6: 1.684085
center of distortion in Z=1 plane, x: 0.000000
center of distortion in Z=1 plane, y: 0.000000
tangential distortion coefficient x: 0.000927
tangential distortion coefficient y: -0.000091
metric radius: 0.000000

參考資料

???????[1]https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/1282#issuecomment-657684355文章來源地址http://www.zghlxwxcb.cn/news/detail-412297.html

到了這里,關于Azure Kinect獲取相機內參的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 基于多臺azure kinects的點云采集、配準、相加

    基于多臺azure kinects的點云采集、配準、相加

    本文采用多臺Azure kinect實現(xiàn)了對人體的動態(tài)捕捉 如果你是剛接觸kinect的小白,建議認真閱讀Microsoft給出的官方文檔 如果你打算自己開發(fā)azure kinect的程序,請參考官方的SDK手冊 如果你想在win下配置azure kinect的開發(fā)環(huán)境,請參考我的上一篇文章 在linux下配置azure kinect會復雜一些

    2024年02月06日
    瀏覽(23)
  • 【Kinect】Ubuntu20.04 安裝Azure Kinect Sensor

    【Kinect】Ubuntu20.04 安裝Azure Kinect Sensor

    本文主要記錄Ubuntu20.04 安裝Azure Kinect Sensor SDK Azure Kinect 人體跟蹤 SDK官網(wǎng) : https://learn.microsoft.com/zh-cn/azure/Kinect-dk/body-sdk-download Linux版本目前只支持 18.04 和 20.04 Azure Kinect 傳感器 SDK 官網(wǎng): https://learn.microsoft.com/zh-cn/azure/Kinect-dk/sensor-sdk-download Linux版本目前只支持 18.04 ,但也能

    2024年02月06日
    瀏覽(26)
  • Azure Kinect 使用記錄 (一)

    Azure Kinect 使用記錄 (一)

    20211111 - 占坑 20211115 - 添加vs編譯內容 20220311 - k4abt_simple_3d_viewer 突然用不了了 因項目需要,得用Azure Kinect以及它的SDK進行開發(fā),在這里記錄下心得體會,不定時更新 1.0 k4abt_simple_3d_viewer 閃退 之前用著還好好的,突然就用不了了,表現(xiàn)情況是,雙擊 k4abt_simple_3d_viewer.exe ,出現(xiàn)

    2024年02月06日
    瀏覽(16)
  • Azure Kinect 之 Note(一)

    Azure Kinect 之 Note(一)

    Azure Kinect DK 是一款開發(fā)人員工具包,配有先進的AI 傳感器,提供復雜的計算機視覺和語音模型。 Kinect 將深度傳感器、空間麥克風陣列與視頻攝像頭和方向傳感器整合成一體式的小型設備,提供多種模式、選項和軟件開發(fā)工具包(SDK)。 https://learn.microsoft.com/zh-tw/azure/kinect-dk/h

    2024年02月16日
    瀏覽(14)
  • Azure Kinect 內置姿勢識別 兩種方法

    Azure Kinect 內置姿勢識別 兩種方法

    第一種方式:(適合單個姿勢識別,多個場景多個姿勢等復雜檢測也可以實現(xiàn),但是可能需要多創(chuàng)建幾個類似腳本) 添加你要識別的內置姿勢即可? ?KinectManager?增加用戶時添加個調用 ??PoseDetector.Instance.UserWasAdded(userId, uidIndex); 隨便放哪里,這里識別的?必須在面板上添加你

    2024年02月09日
    瀏覽(20)
  • Azure kinect (二)項目創(chuàng)建和環(huán)境配置

    Azure kinect (二)項目創(chuàng)建和環(huán)境配置

    在此之前,你需要安裝Microsoft Visual Studio,本人先使用的是2019版本,后轉用2022版本,如版本問題對項目創(chuàng)建和環(huán)境配置產(chǎn)生影響,歡迎咨詢。 新建一個C++空項目 創(chuàng)建完成后,將是以下界面,已經(jīng)熟悉Visual Studio的朋友們可跳過, 右鍵項目,進入屬性設置 在鏈接器 -- 輸入 —

    2024年02月10日
    瀏覽(21)
  • 史上最全Azure Kinect相關安裝教程

    史上最全Azure Kinect相關安裝教程

    本教程旨在向無Azure Kinect開發(fā)經(jīng)驗的新手進行相關環(huán)境的安裝。 https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/develop/docs/usage.md 安裝 SDK 時,請記住要安裝到的路徑。 例如,“C:Program FilesAzure Kinect SDK 1.2”。 你將要在此路徑中查找文章中參考的工具。此處建議按照默認位置安

    2024年02月07日
    瀏覽(32)
  • Azure Kinect微軟攝像頭Unity開發(fā)小結

    Azure Kinect微軟攝像頭Unity開發(fā)小結

    Azure Kienct是微軟的代替Kinect的攝像頭,用處其實蠻多的,最近做了這個的一些開發(fā),總結一下。 如果只是當普通攝像頭用的話,有集成顯卡就行了。如果要用人體跟蹤,至少要1050的獨顯。 微軟攝像頭代的東西還不少,可以建立點云地圖,但是沒試過。 下面是官方的SDK。后面

    2024年02月04日
    瀏覽(23)
  • Unity 結合 Azure Kinect 開發(fā)體感游戲教程

    本教程將介紹如何使用 Unity 和 Azure Kinect SDK 開發(fā)體感游戲。我們將重點介紹環(huán)境安裝和手勢的實現(xiàn)。 1. 準備工作 確保你已經(jīng)擁有以下硬件和軟件: Azure Kinect DK 設備 Windows 10 Unity 2020或更高版本 Visual Studio 2019或更高版本 2. 安裝 Azure Kinect SDK 訪問 Azure Kinect DK 官方頁面 并下載

    2024年02月03日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包