프로그램 사용/kinect2026. 9. 19. 15:25

MME. 라는 식별자가 붙네

USB VID/PID는 어디로 간거야?

 

audacity 에서도 MME 라고 나오던데

찾아보니 Microsoft Multimedia Environment 라고 하는데 win 3.1 시절부터 있던 녀석이라고 한다.

[링크 : https://musicnomad.tistory.com/126]

 

 

예전에 오디오 프로그램 관련에서 WASAPI가 딜레이도 적고(지터) 좋다고 하던데 비트 퍼펙트니 머니

Windows Audio Session API의 약자라고 한다.

아무튼 이걸로 하면 4채널로 뜬다.

 

SDK 샘플 브라우저에도 Audio Demo가 보이네

생각해보니.. kinect v1은 윈도우에서 실행도 안해봤었나? 기억이 저~~~언혀 안나네?

 

v1이나 v2나 출력내용은 동일하다. 각도, 정확도.

Posted by 구차니
프로그램 사용/kinect2026. 9. 19. 15:11

sdk browser에 버젓이 있었는데 kinect니까! 당연히 영상이지! 라고만 생각했었나 보다.

 

Audio Basics-D2D

 

Audio Basics-WPF

 

소리, 소리의 각도, 확신성? 이렇게 나오는것 같긴한데

좌우로 오가면서 하면 잘 찾는듯 하면서 의외로 잘 못찾는것 같기도 하다.

 

Audio Capture-Cosole(Raw)는 장치를 못 찾는다고 나오네. 머지?

관리자 모드로 해도 안되는건 여전하다. 그래서 audacity 에서도 오작동하는건가?

 

사운드, 비디오 및 게임 컨트롤러에서는

Xbox NUI Sensor라고 뜨나보다.

 

그나저나 audacity 윈도우 버전에서는 MME와 Windows DirectSound로는 2채널로만 잡히네..

 

MME랑 DirectSound로는 2채널이지만 녹음이 잘 된다.

 

Windows WASAPI로 해야지 4채널 장치로 잡힌다.

 

그런데 녹음하려고 하면 44100 으로 되어있는데 안되네? 멀까?

 

'프로그램 사용 > kinect' 카테고리의 다른 글

kinect for windows v1 audio  (0) 2026.09.19
kinect for windows / linux 에서 4채널 사운드 입력 받기  (0) 2026.09.18
ODAS TDoA  (0) 2026.09.08
libfreenect2 VAAPI 버그?  (2) 2025.05.22
kinect 1.x, 2.x color <-> depth mapping  (0) 2025.05.07
Posted by 구차니
프로그램 사용/kinect2026. 9. 18. 15:28

음.. 리눅스에서는 안되네 sdk 깔고 윈도우에서 보면 4채널 녹음 가능한 걸로 뜨려나?

응 아니야~ 

$ arecord -l
**** CAPTURE 하드웨어 장치 목록 ****
카드 0: sofhdadsp [sof-hda-dsp], 장치 0: HDA Analog (*) []
  주변장치: 1/1
  주변장치 #0: subdevice #0
카드 0: sofhdadsp [sof-hda-dsp], 장치 1: HDA Digital (*) []
  주변장치: 1/1
  주변장치 #0: subdevice #0
카드 0: sofhdadsp [sof-hda-dsp], 장치 6: DMIC (*) []
  주변장치: 1/1
  주변장치 #0: subdevice #0
카드 0: sofhdadsp [sof-hda-dsp], 장치 7: DMIC16kHz (*) []
  주변장치: 1/1
  주변장치 #0: subdevice #0

 

먼가 깔아야 한다고 해서 시도. 응 실패

$ sudo apt install kinect-audio-setup
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
다음 새 패키지를 설치할 것입니다:
  kinect-audio-setup
0개 업그레이드, 1개 새로 설치, 0개 제거 및 13개 업그레이드 안 함.
16.3 k바이트 아카이브를 받아야 합니다.
이 작업 후 59.4 k바이트의 디스크 공간을 더 사용하게 됩니다.
받기:1 http://kr.archive.ubuntu.com/ubuntu jammy/multiverse amd64 kinect-audio-setup amd64 0.5-1build1 [16.3 kB]
내려받기 16.3 k바이트, 소요시간 1초 (31.8 k바이트/초)
패키지를 미리 설정하는 중입니다...
Selecting previously unselected package kinect-audio-setup.
(데이터베이스 읽는중 ...현재 486157개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../kinect-audio-setup_0.5-1build1_amd64.deb ...
Unpacking kinect-audio-setup (0.5-1build1) ...
kinect-audio-setup (0.5-1build1) 설정하는 중입니다 ...

This script is going to download the UAC Firmware for the Microsoft
Kinect Sensor device from the Microsoft Kinect for Windows SDK:
http://kinectforwindows.org/

The full license of the SDK can be found at:
http://research.microsoft.com/en-us/um/legal/kinectsdk-tou_noncommercial.htm

--2026-09-18 14:39:10--  http://download.microsoft.com/download/F/9/9/F99791F2-D5BE-478A-B77A-830AD14950C3/KinectSDK-v1.0-beta2-x86.ms
i
download.microsoft.com (download.microsoft.com) 해석 중... 23.40.26.11, 2600:140b:2c00:597::317f, 2600:140b:2c00:589::317f
다음으로 연결 중: download.microsoft.com (download.microsoft.com)|23.40.26.11|:80... 연결했습니다.
HTTP 요청을 보냈습니다. 응답 기다리는 중... 302 Moved Temporarily
위치: https://download.microsoft.com/download/F/9/9/F99791F2-D5BE-478A-B77A-830AD14950C3/KinectSDK-v1.0-beta2-x86.msi [따라감]
--2026-09-18 14:39:10--  https://download.microsoft.com/download/F/9/9/F99791F2-D5BE-478A-B77A-830AD14950C3/KinectSDK-v1.0-beta2-x86.m
si
다음으로 연결 중: download.microsoft.com (download.microsoft.com)|23.40.26.11|:443... 연결했습니다.
HTTP 요청을 보냈습니다. 응답 기다리는 중... 200 OK
길이: 21823488 (21M) [application/octet-stream]
저장 위치: ‘KinectSDK-v1.0-beta2-x86.msi’

KinectSDK-v1.0-beta2-x86.msi      100%[===========================================================>]  20.81M  6.25MB/s    / 3.3s     

2026-09-18 14:39:14 (6.25 MB/s) - ‘KinectSDK-v1.0-beta2-x86.msi’ 저장함 [21823488/21823488]

kinect_fetch_fw: Invalid hash for file 'KinectSDK-v1.0-beta2-x86.msi'.
dpkg: error processing package kinect-audio-setup (--configure):
 installed kinect-audio-setup package post-installation script 서브프로세스가 오류 종료 상태 1를 반환했습니다
Processing triggers for man-db (2.10.2-1) ...
처리하는데 오류가 발생했습니다:
 kinect-audio-setup
E: Sub-process /usr/bin/dpkg returned an error code (1)

 

구글 AI 답변을 따라서 해당 부분 주석처리

$ sudo vi /usr/sbin/kinect_fetch_fw 
 50 #if [ "$ARCHIVE_MD5" != "$SDK_MD5" ];
 51 #then
 52 #  echo "$(basename "$0"): Invalid hash for file '$ARCHIVE_NAME'." 1>&2
 53 #  exit 1
 54 #fi

 

재설치 하니 성공

$ sudo apt install kinect-audio-setup
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
패키지 kinect-audio-setup는 이미 최신 버전입니다 (0.5-1build1).
0개 업그레이드, 0개 새로 설치, 0개 제거 및 13개 업그레이드 안 함.
1개를 완전히 설치하지 못했거나 지움.
이 작업 후 0 바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] 
kinect-audio-setup (0.5-1build1) 설정하는 중입니다 ...

This script is going to download the UAC Firmware for the Microsoft
Kinect Sensor device from the Microsoft Kinect for Windows SDK:
http://kinectforwindows.org/

The full license of the SDK can be found at:
http://research.microsoft.com/en-us/um/legal/kinectsdk-tou_noncommercial.htm

--2026-09-18 14:58:59--  http://download.microsoft.com/download/F/9/9/F99791F2-D
5BE-478A-B77A-830AD14950C3/KinectSDK-v1.0-beta2-x86.msi
download.microsoft.com (download.microsoft.com) 해석 중... 2.18.102.60, 2600:140
b:2c00:597::317f, 2600:140b:2c00:589::317f
다음으로 연결 중: download.microsoft.com (download.microsoft.com)|2.18.102.60|:8
0... 연결했습니다.
HTTP 요청을 보냈습니다. 응답 기다리는 중... 302 Moved Temporarily
위치: https://download.microsoft.com/download/F/9/9/F99791F2-D5BE-478A-B77A-830A
D14950C3/KinectSDK-v1.0-beta2-x86.msi [따라감]
--2026-09-18 14:58:59--  https://download.microsoft.com/download/F/9/9/F99791F2-
D5BE-478A-B77A-830AD14950C3/KinectSDK-v1.0-beta2-x86.msi
다음으로 연결 중: download.microsoft.com (download.microsoft.com)|2.18.102.60|:4
43... 연결했습니다.
HTTP 요청을 보냈습니다. 응답 기다리는 중... 200 OK
길이: 21823488 (21M) [application/octet-stream]
저장 위치: ‘KinectSDK-v1.0-beta2-x86.msi’

KinectSDK-v1.0-beta 100%[===================>]  20.81M  3.79MB/s    / 5.7s     

2026-09-18 14:59:06 (3.62 MB/s) - ‘KinectSDK-v1.0-beta2-x86.msi’ 저장함 [21823488/21823488]

Extracting the UAC firmware... done.

 

먼가 파일이 있는데

$ ls -al /lib/firmware/kinect/
합계 216
drwxr-xr-x  2 root root   4096  9월 18 14:59 .
drwxr-xr-x 93 root root  77824  9월 18 14:59 ..
-rw-r--r--  1 root root 132096  9월 18 14:59 UACFirmware

 

udev도 추가되어있는데 반응이 없다.

$ cat /lib/udev/rules.d/*kinect*
# Rule to load the Kinect UAC firmware on the "generic" usb device
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="02ad", RUN+="/usr/sbin/kinect_upload_fw /lib/firmware/kinect/UACFirmware"

 

일단은 claude 답으로는 xbox360 용이 아닌 kienct for windows 라서 pid가 다르다고 한다.

$ sudo kinect_upload_fw /lib/firmware/kinect/UACFirmware
libusb_open failed: Resource temporarily unavailable

 

오디오가 02be 인데 이건 kinect for windows 용 PID

02ad가 나와야 xbox 360 kinect 라고 한다. 그런데.. 리눅스에서 하려면 원래 오리지널을 써야하나?

$ lsusb | grep -i 045e
Bus 001 Device 036: ID 045e:02bf Microsoft Corp. Kinect for Windows NUI Camera
Bus 001 Device 035: ID 045e:02be Microsoft Corp. Kinect for Windows NUI Audio
Bus 001 Device 034: ID 045e:02c2 Microsoft Corp. Kinect for Windows NUI Motor

 

이게 오리지널인가?

[링크 : https://git.ao2.it/kinect-audio-setup.git/] 

    [링크 : https://github.com/dev-0x7C6/kinect-audio-setup]

 

와.. ai 만세

일단 오리지널 소스 찾았고 그걸로 소스 바꾸어서 빌드하면 된다.

$ sudo apt install git build-essential libusb-1.0-0-dev pkg-config
$ git clone https://git.ao2.it/kinect-audio-setup.git
$ cd kinect-audio-setup/kinect_upload_fw
$ sed -i 's/#define KINECT_AUDIO_PID           0x02ad/#define KINECT_AUDIO_PID           0x02be/' kinect_upload_fw.c
$ grep -n KINECT_AUDIO_PID kinect_upload_fw.c   # 0x02be로 바뀌었는지 확인
$ make
$ sudo ./kinect_upload_fw /lib/firmware/kinect/UACFirmware
About to send: 09 20 02 06 01 00 00 00 60 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 
Reading first reply: 02 00 01 00 00 00 00 00 8A 03 00 00 02 00 01 00 00 00 00 00 8A 03 00 00 02 00 01 00 00 00 00 00 8A 03 00 00 F8 FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 01 00 00 00 00 00 00 00 
About to send: 09 20 02 06 02 00 00 00 00 40 00 00 03 00 00 00 00 00 08 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 02 00 00 00 00 00 00 00 
About to send: 09 20 02 06 03 00 00 00 00 40 00 00 03 00 00 00 00 40 08 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 03 00 00 00 00 00 00 00 
About to send: 09 20 02 06 04 00 00 00 00 40 00 00 03 00 00 00 00 80 08 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 04 00 00 00 00 00 00 00 
About to send: 09 20 02 06 05 00 00 00 00 40 00 00 03 00 00 00 00 C0 08 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 05 00 00 00 00 00 00 00 
About to send: 09 20 02 06 06 00 00 00 00 40 00 00 03 00 00 00 00 00 09 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 06 00 00 00 00 00 00 00 
About to send: 09 20 02 06 07 00 00 00 00 40 00 00 03 00 00 00 00 40 09 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 07 00 00 00 00 00 00 00 
About to send: 09 20 02 06 08 00 00 00 00 40 00 00 03 00 00 00 00 80 09 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 08 00 00 00 00 00 00 00 
About to send: 09 20 02 06 09 00 00 00 00 40 00 00 03 00 00 00 00 C0 09 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 09 00 00 00 00 00 00 00 
About to send: 09 20 02 06 0A 00 00 00 00 04 00 00 03 00 00 00 00 00 0A 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 0A 00 00 00 00 00 00 00 
09 20 02 06 0B 00 00 00 00 00 00 00 04 00 00 00 30 00 08 00 00 00 00 00 
Reading reply: 00 E0 6F 0A 0B 00 00 00 00 00 00 00 
falinux@falinux-730QCJ-730QCR:~/work/src/kinect-audio-setup/kinect_upload_fw$ lsusb | grep -i 045e
Bus 001 Device 039: ID 045e:02bf Microsoft Corp. Kinect for Windows NUI Camera
Bus 001 Device 040: ID 045e:02bb Microsoft Corp. Kinect Audio
Bus 001 Device 037: ID 045e:02c2 Microsoft Corp. Kinect for Windows NUI Motor

$ arecord -l
**** CAPTURE 하드웨어 장치 목록 ****
카드 0: sofhdadsp [sof-hda-dsp], 장치 0: HDA Analog (*) []
  주변장치: 1/1
  주변장치 #0: subdevice #0
카드 0: sofhdadsp [sof-hda-dsp], 장치 1: HDA Digital (*) []
  주변장치: 1/1
  주변장치 #0: subdevice #0
카드 0: sofhdadsp [sof-hda-dsp], 장치 6: DMIC (*) []
  주변장치: 1/1
  주변장치 #0: subdevice #0
카드 0: sofhdadsp [sof-hda-dsp], 장치 7: DMIC16kHz (*) []
  주변장치: 1/1
  주변장치 #0: subdevice #0
카드 1: Audio [Kinect USB Audio], 장치 0: USB Audio [USB Audio]
  주변장치: 1/1
  주변장치 #0: subdevice #0

 

녹음 장치로 kinect usb audio가 뜬다. 최대 4채널

 

방향을 까먹음 오른쪽, 뒤, 왼쪽, 앞이었나?

채널별로 파형의 시작 위치나, 강도가 다르게 보이는거 보면 먼가 맞긴 한가보다.

 

 

 

정면 에서 딱!

 

우측

 

뒤 - 마이크가 전반적으로 앞을 향해있나.. 엄청 약하네

 

왼쪽 

 

'프로그램 사용 > kinect' 카테고리의 다른 글

kinect for windows v1 audio  (0) 2026.09.19
kinect for windows v2 / 오디오 예제  (0) 2026.09.19
ODAS TDoA  (0) 2026.09.08
libfreenect2 VAAPI 버그?  (2) 2025.05.22
kinect 1.x, 2.x color <-> depth mapping  (0) 2025.05.07
Posted by 구차니

kinect 에서 사운드 array를 이용해서 방향을 측정할수 있다곤 하는데

libfreenect 에는 사운드 관련 api가 존재 하지만

libfreenect2 에서는 아예 없어서 odas나 tdoa 라이브러리 쓰라고 해서 찾아보는 중

 

ODAS (Open embeddeD Audition System) 

[링크 : https://github.com/introlab/odas]

[링크 : https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2022.854444/full]





TWR (Two Way Ranging)

TDoA (Time Differnce of Arrival)

[링크 : https://github.com/AlexisTM/MultilaterationTDOA]

[링크 : https://grow-space.io/blog/uwb-측위-방식의-양대-산맥-twrtwo-way-ranging-vs-tdoatime-difference-of-arrival-비교/]

[링크 : https://m.blog.naver.com/intknk2/221510943339]

Posted by 구차니
프로그램 사용/kinect2025. 5. 22. 23:51

intel 7세대 노트북에서

별 옵션 주지 않고 cmake 하니까 아래와 같이 설정이 된다.

2세대 에서는 OpenCL yes, VAAPI no 였다.

-- Using in-tree freenect2 target
-- Feature list:
--   CUDA    no
--   CXX11    disabled
--   Examples    yes
--   OpenCL    no
--   OpenGL    yes
--   OpenNI2    yes
--   TegraJPEG    no
--   Threading    tinythread
--   TurboJPEG    yes
--   VAAPI    yes
--   VideoToolbox    no (Apple only)
--   streamer_recorder    disabled
-- Configuring done (0.1s)
-- Generating done (0.0s)

 

그래서 떴던거 같아서 다시 실행해보니 ir 과 depth는 정상이고 rgb의 폭이 이상해서

3d로 재구성된 녀석도 이상하게 나온다.

$ ./Protonect 
Version: 0.2.0
Environment variables: LOGFILE=<protonect.log>
Usage: ./Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]
        [-noviewer] [-norgb | -nodepth] [-help] [-version]
        [-frames <number of frames to process>]
To pause and unpause: pkill -USR1 Protonect
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 9 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @2:11 with serial 501441643042
[Info] [Freenect2Impl] found 1 devices
libva info: VA-API version 1.20.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
[Info] [VaapiRgbPacketProcessorImpl] driver: Intel iHD driver for Intel(R) Gen Graphics - 24.1.0 ()
[Info] [Freenect2DeviceImpl] opening...
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792
[Info] [Freenect2DeviceImpl] opened
[Info] [Freenect2DeviceImpl] starting...
[Debug] [Freenect2DeviceImpl] status 0x090000: 9729
[Debug] [Freenect2DeviceImpl] status 0x090000: 9731
[Info] [Freenect2DeviceImpl] submitting rgb transfers...
[Info] [Freenect2DeviceImpl] submitting depth transfers...
[Info] [Freenect2DeviceImpl] started

 

그래서 VAAPI를 끄고 빌드해서 실행해보니

$ cmake .. -DENABLE_VAAPI=OFF
-- Using in-tree freenect2 target
-- Feature list:
--   CUDA    no
--   CXX11    disabled
--   Examples    yes
--   OpenCL    no
--   OpenGL    yes
--   OpenNI2    yes
--   TegraJPEG    no
--   Threading    tinythread
--   TurboJPEG    yes
--   VAAPI    disabled
--   VideoToolbox    no (Apple only)
--   streamer_recorder    disabled
-- Configuring done (0.1s)
-- Generating done (0.0s)

 

영상은 정상적으로 보이는데, transfer pool size가 달라지진 않네.. 머지?

$ ./Protonect 
Version: 0.2.0
Environment variables: LOGFILE=<protonect.log>
Usage: ./Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]
        [-noviewer] [-norgb | -nodepth] [-help] [-version]
        [-frames <number of frames to process>]
To pause and unpause: pkill -USR1 Protonect
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 9 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @2:11 with serial 501441643042
[Info] [Freenect2Impl] found 1 devices
[Info] [Freenect2DeviceImpl] opening...
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792
[Info] [Freenect2DeviceImpl] opened
[Info] [Freenect2DeviceImpl] starting...
[Debug] [Freenect2DeviceImpl] status 0x090000: 9729
[Debug] [Freenect2DeviceImpl] status 0x090000: 9731
[Info] [Freenect2DeviceImpl] submitting rgb transfers...
[Info] [Freenect2DeviceImpl] submitting depth transfers...
[Debug] [DepthPacketStreamParser] not all subsequences received 0
[Info] [Freenect2DeviceImpl] started

 

 

Posted by 구차니

링크와는 다르게 내용상으로는 preview 시절(?) api 같은데

colorframe -> depth

public void MapColorFrameToDepthSpace (
         Array<UInt16>[] depthFrameData,
         out Array<DepthSpacePoint>[] depthSpacePoints
)

[링크 : https://learn.microsoft.com/en-us/previous-versions/windows/kinect/dn791296(v=ieb.10)?redirectedfrom=MSDN]

 

depth -> colorframe 가 존재한다.

public void MapDepthFrameToCameraSpace (
         Array<UInt16>[] depthFrameData,
         out Array<CameraSpacePoint>[] cameraSpacePoints
)

[링크 : https://learn.microsoft.com/en-us/previous-versions/windows/kinect/dn791303(v=ieb.10)?redirectedfrom=MSDN]

    [링크 : https://learn.microsoft.com/en-us/previous-versions/windows/kinect/dn758445(v=ieb.10)?redirectedfrom=MSDN]

 

v1.8에도 존재 (링크 사라짐)

[링크 : https://learn.microsoft.com/en-us/previous-versions/windows/kinect-1.8/jj663707(v=ieb.10)]

   [링크 : https://stackoverflow.com/questions/17012585/how-do-you-map-kinects-depth-data-to-its-rgb-color]

 

그래서 함수 명으로 검색했는데 좀 이름이 다르다.

HRESULT MapDepthFrameToColorFrame(
         NUI_IMAGE_RESOLUTION eDepthResolution,
         DWORD cDepthPixels,
         NUI_DEPTH_IMAGE_PIXEL *pDepthPixels,
         NUI_IMAGE_TYPE eColorType,
         NUI_IMAGE_RESOLUTION eColorResolution,
         DWORD cColorPoints,
         NUI_COLOR_IMAGE_POINT *pColorPoints
)

[링크 : https://learn.microsoft.com/en-us/previous-versions/windows/kinect-1.8/jj883691(v=ieb.10)]

 

HRESULT MapColorFrameToDepthFrame(
         NUI_IMAGE_TYPE eColorType,
         NUI_IMAGE_RESOLUTION eColorResolution,
         NUI_IMAGE_RESOLUTION eDepthResolution,
         DWORD cDepthPixels,
         NUI_DEPTH_IMAGE_PIXEL *pDepthPixels,
         DWORD cDepthPoints,
         NUI_DEPTH_IMAGE_POINT *pDepthPoints
)

[링크 : https://learn.microsoft.com/en-us/previous-versions/windows/kinect-1.8/jj883688(v=ieb.10)]

'프로그램 사용 > kinect' 카테고리의 다른 글

ODAS TDoA  (0) 2026.09.08
libfreenect2 VAAPI 버그?  (2) 2025.05.22
kinect v2 잘못된 깊이 맵 맵핑  (0) 2025.05.06
libfreenect2 rgb / depth 매핑 소스코드 분석  (0) 2025.05.05
kinect rgb - depth mapping  (0) 2025.05.01
Posted by 구차니

심심해서(?) 실행해봤는데 어라...

아무래도 depth 카메라와 rgb 카메라의 거리가 떨어져있어서 시차로 인한 오류가 발생을 하는지

특수한 각도에서는 다음과 같이 이상하게 맵핑이 된다.

(노트북 뒤로 몽둥이를 들고 있는데 3d로 합성된 쪽에서는 투명하게 뚫는 것 처럼 보임)

libfreenect2의 한계인가.. 아니면 윈도우 버전도 이럴려나?

'프로그램 사용 > kinect' 카테고리의 다른 글

libfreenect2 VAAPI 버그?  (2) 2025.05.22
kinect 1.x, 2.x color <-> depth mapping  (0) 2025.05.07
libfreenect2 rgb / depth 매핑 소스코드 분석  (0) 2025.05.05
kinect rgb - depth mapping  (0) 2025.05.01
kinect 깊이 정밀도  (0) 2025.04.15
Posted by 구차니

libfreenect2 내의 매핑 코드가 이해가 안되서 다른걸 찾아보는데 여전히 이해가 안된다..

코드 상으로는 크게 차이가 없는 것 같지만, color map에 depth map을 합성하는게 더 자연스러워 보이는 것 같다.

The following snippet shows us how to locate the color bytes from the ColorSpacePoint:

// we need a starting point, let's pick 0 for now
int index = 0;
 
ushort depth = _depthData[index];
ColorSpacePoint point = _colorSpacePoints[index];
 
// round down to the nearest pixel
int colorX = (int)Math.Floor(point.X + 0.5);
int colorY = (int)Math.Floor(point.Y + 0.5);
 
// make sure the pixel is part of the image
if ((colorX >= 0 && (colorX < colorWidth) && (colorY >= 0) && (colorY < colorHeight))
{
 
    int colorImageIndex = ((colorWidth * colorY) + colorX) * bytesPerPixel;
 
    byte b = _colorFrameData[colorImageIndex];
    byte g = _colorFrameData[colorImageIndex + 1];
    byte r = _colorFrameData[colorImageIndex + 2];
    byte a = _colorFrameData[colorImageIndex + 3];
 
}

 

그나저나 depth sensor가 더 FOV가 넓어서 왜곡되다보니

depth map에 맵핑했을 경우에는 lens 왜곡 보정을 한 것 같기도 한데

코드 상에는 별 내용이 없는 것 같기도 하고.. 멀 한거지?

// clear the pixels before we color them
Array.Clear(_pixels, 0, _pixels.Length);
 
for (int depthIndex = 0; depthIndex < _depthData.Length; ++depthIndex)
{
    ColorSpacePoint point = _colorSpacePoints[depthIndex];
 
    int colorX = (int)Math.Floor(point.X + 0.5);
    int colorY = (int)Math.Floor(point.Y + 0.5);
    if ((colorX >= 0) && (colorX < colorWidth) && (colorY >= 0) && (colorY < colorHeight))
    {
        int colorImageIndex = ((colorWidth * colorY) + colorX) * bytesPerPixel;
        int depthPixel = depthIndex * bytesPerPixel;
 
        _pixels[depthPixel] = _colorData[colorImageIndex];
        _pixels[depthPixel + 1] = _colorData[colorImageIndex + 1];
        _pixels[depthPixel + 2] = _colorData[colorImageIndex + 2];
        _pixels[depthPixel + 3] = 255;
    }
}

[링크 : https://www.bryancook.net/2014/03/mapping-between-kinect-color-and-depth.html]

    [링크 : https://stackoverflow.com/questions/29479746/kinect-v2-color-depth-mapping-using-c-sharp]

[링크 : https://kr.mathworks.com/matlabcentral/answers/268152-mapping-rgb-and-depth-kinect-v2]

[링크 : https://learn.microsoft.com/en-us/previous-versions/windows/kinect/dn758445(v=ieb.10)?redirectedfrom=MSDN]

    [링크 : https://tommyhsm.tistory.com/124]

 

libfreenct의 Protonect 실행하는 부분에서, rgb와 depth를 어떻게 매핑하는지 궁금해서 찾아보는데 크게 자료가 있진 않다.

/// [registration setup]
  libfreenect2::Registration* registration = new libfreenect2::Registration(dev->getIrCameraParams(), dev->getColorCameraParams());
  libfreenect2::Frame undistorted(512, 424, 4), registered(512, 424, 4);

/// [loop start]
  while(!protonect_shutdown && (framemax == (size_t)-1 || framecount < framemax))
  {
    if (!listener.waitForNewFrame(frames, 10*1000)) // 10 sconds
    {
      std::cout << "timeout!" << std::endl;
      return -1;
    }
    libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color];
    libfreenect2::Frame *ir = frames[libfreenect2::Frame::Ir];
    libfreenect2::Frame *depth = frames[libfreenect2::Frame::Depth];
/// [loop start]

    if (enable_rgb && enable_depth)
    {
/// [registration]
      registration->apply(rgb, depth, &undistorted, &registered);
/// [registration]
    }

    framecount++;
    if (!viewer_enabled)
    {
      if (framecount % 100 == 0)
        std::cout << "The viewer is turned off. Received " << framecount << " frames. Ctrl-C to stop." << std::endl;
      listener.release(frames);
      continue;
    }

#ifdef EXAMPLES_WITH_OPENGL_SUPPORT
    if (enable_rgb)
    {
      viewer.addFrame("RGB", rgb);
    }
    if (enable_depth)
    {
      viewer.addFrame("ir", ir);
      viewer.addFrame("depth", depth);
    }
    if (enable_rgb && enable_depth)
    {
      viewer.addFrame("registered", &registered);
    }

    protonect_shutdown = protonect_shutdown || viewer.render();
#endif

/// [loop end]
    listener.release(frames);
    /** libfreenect2::this_thread::sleep_for(libfreenect2::chrono::milliseconds(100)); */
  }
/// [loop end]

[링크 : https://github.com/OpenKinect/libfreenect2/blob/fd64c5d9b214df6f6a55b4419357e51083f15d93/examples/Protonect.cpp#L348]

void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter, Frame *bigdepth, int *color_depth_map) const
{
  impl_->apply(rgb, depth, undistorted, registered, enable_filter, bigdepth, color_depth_map);
}

void RegistrationImpl::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter, Frame *bigdepth, int *color_depth_map) const
{
  // Check if all frames are valid and have the correct size
  if (!rgb || !depth || !undistorted || !registered ||
      rgb->width != 1920 || rgb->height != 1080 || rgb->bytes_per_pixel != 4 ||
      depth->width != 512 || depth->height != 424 || depth->bytes_per_pixel != 4 ||
      undistorted->width != 512 || undistorted->height != 424 || undistorted->bytes_per_pixel != 4 ||
      registered->width != 512 || registered->height != 424 || registered->bytes_per_pixel != 4)
    return;

  const float *depth_data = (float*)depth->data;
  const unsigned int *rgb_data = (unsigned int*)rgb->data;
  float *undistorted_data = (float*)undistorted->data;
  unsigned int *registered_data = (unsigned int*)registered->data;
  const int *map_dist = distort_map;
  const float *map_x = depth_to_color_map_x;
  const int *map_yi = depth_to_color_map_yi;

  const int size_depth = 512 * 424;
  const int size_color = 1920 * 1080;
  const float color_cx = color.cx + 0.5f; // 0.5f added for later rounding

  // size of filter map with a border of filter_height_half on top and bottom so that no check for borders is needed.
  // since the color image is wide angle no border to the sides is needed.
  const int size_filter_map = size_color + 1920 * filter_height_half * 2;
  // offset to the important data
  const int offset_filter_map = 1920 * filter_height_half;

  // map for storing the min z values used for each color pixel
  float *filter_map = NULL;
  // pointer to the beginning of the important data
  float *p_filter_map = NULL;

  // map for storing the color offset for each depth pixel
  int *depth_to_c_off = color_depth_map ? color_depth_map : new int[size_depth];
  int *map_c_off = depth_to_c_off;

  // initializing the depth_map with values outside of the Kinect2 range
  if(enable_filter){
    filter_map = bigdepth ? (float*)bigdepth->data : new float[size_filter_map];
    p_filter_map = filter_map + offset_filter_map;

    for(float *it = filter_map, *end = filter_map + size_filter_map; it != end; ++it){
      *it = std::numeric_limits<float>::infinity();
    }
  }

  /* Fix depth distortion, and compute pixel to use from 'rgb' based on depth measurement,
   * stored as x/y offset in the rgb data.
   */

  // iterating over all pixels from undistorted depth and registered color image
  // the four maps have the same structure as the images, so their pointers are increased each iteration as well
  for(int i = 0; i < size_depth; ++i, ++undistorted_data, ++map_dist, ++map_x, ++map_yi, ++map_c_off){
    // getting index of distorted depth pixel
    const int index = *map_dist;

    // check if distorted depth pixel is outside of the depth image
    if(index < 0){
      *map_c_off = -1;
      *undistorted_data = 0;
      continue;
    }

    // getting depth value for current pixel
    const float z = depth_data[index];
    *undistorted_data = z;

    // checking for invalid depth value
    if(z <= 0.0f){
      *map_c_off = -1;
      continue;
    }

    // calculating x offset for rgb image based on depth value
    const float rx = (*map_x + (color.shift_m / z)) * color.fx + color_cx;
    const int cx = rx; // same as round for positive numbers (0.5f was already added to color_cx)
    // getting y offset for depth image
    const int cy = *map_yi;
    // combining offsets
    const int c_off = cx + cy * 1920;

    // check if c_off is outside of rgb image
    // checking rx/cx is not needed because the color image is much wider then the depth image
    if(c_off < 0 || c_off >= size_color){
      *map_c_off = -1;
      continue;
    }

    // saving the offset for later
    *map_c_off = c_off;

    if(enable_filter){
      // setting a window around the filter map pixel corresponding to the color pixel with the current z value
      int yi = (cy - filter_height_half) * 1920 + cx - filter_width_half; // index of first pixel to set
      for(int r = -filter_height_half; r <= filter_height_half; ++r, yi += 1920) // index increased by a full row each iteration
      {
        float *it = p_filter_map + yi;
        for(int c = -filter_width_half; c <= filter_width_half; ++c, ++it)
        {
          // only set if the current z is smaller
          if(z < *it)
            *it = z;
        }
      }
    }
  }

  /* Construct 'registered' image. */

  // reseting the pointers to the beginning
  map_c_off = depth_to_c_off;
  undistorted_data = (float*)undistorted->data;

  /* Filter drops duplicate pixels due to aspect of two cameras. */
  if(enable_filter){
    // run through all registered color pixels and set them based on filter results
    for(int i = 0; i < size_depth; ++i, ++map_c_off, ++undistorted_data, ++registered_data){
      const int c_off = *map_c_off;

      // check if offset is out of image
      if(c_off < 0){
        *registered_data = 0;
        continue;
      }
f
      const float min_z = p_filter_map[c_off];
      const float z = *undistorted_data;

      // check for allowed depth noise
      *registered_data = (z - min_z) / z > filter_tolerance ? 0 : *(rgb_data + c_off);
    }

    if (!bigdepth) delete[] filter_map;
  }
  else
  {
    // run through all registered color pixels and set them based on c_off
    for(int i = 0; i < size_depth; ++i, ++map_c_off, ++registered_data){
      const int c_off = *map_c_off;

      // check if offset is out of image
      *registered_data = c_off < 0 ? 0 : *(rgb_data + c_off);
    }
  }
  if (!color_depth_map) delete[] depth_to_c_off;
}

[링크 : https://github.com/OpenKinect/libfreenect2/blob/fd64c5d9b214df6f6a55b4419357e51083f15d93/src/registration.cpp#L123]

'프로그램 사용 > kinect' 카테고리의 다른 글

kinect 1.x, 2.x color <-> depth mapping  (0) 2025.05.07
kinect v2 잘못된 깊이 맵 맵핑  (0) 2025.05.06
kinect rgb - depth mapping  (0) 2025.05.01
kinect 깊이 정밀도  (0) 2025.04.15
libfreenect2 on 2760p 성공  (0) 2024.08.18
Posted by 구차니

보기에는 단순하게 변형하고 잘라서 깊이정보를 주는것 같은데.. 맞나?

[링크 : https://tommyhsm.tistory.com/124]

[링크 : https://www.researchgate.net/publication/340527659_Color_and_depth_mapping_of_Kinect_v2]

[링크 : https://m.blog.naver.com/sense_sciencefiction/221967976514]

'프로그램 사용 > kinect' 카테고리의 다른 글

kinect v2 잘못된 깊이 맵 맵핑  (0) 2025.05.06
libfreenect2 rgb / depth 매핑 소스코드 분석  (0) 2025.05.05
kinect 깊이 정밀도  (0) 2025.04.15
libfreenect2 on 2760p 성공  (0) 2024.08.18
libfreenect2 성공  (0) 2024.07.17
Posted by 구차니
프로그램 사용/kinect2025. 4. 15. 14:55

 

깊이가 선형적으로 나오는 게 아닌건가? 나중에 확인을 해봐야겠다.

 

50cm 에서는 1.5mm 정밀도고 5m 에서는 5cm라..

Depth resolution: ~ 1.5 mm at 50 cm. About 5 cm at 5 m.

[링크 : https://stackoverflow.com/questions/7696436/precision-of-the-kinect-depth-camera]

[링크 : https://pmc.ncbi.nlm.nih.gov/articles/PMC9002889/]

'프로그램 사용 > kinect' 카테고리의 다른 글

libfreenect2 rgb / depth 매핑 소스코드 분석  (0) 2025.05.05
kinect rgb - depth mapping  (0) 2025.05.01
libfreenect2 on 2760p 성공  (0) 2024.08.18
libfreenect2 성공  (0) 2024.07.17
libfreenect2 실행 성공..  (0) 2024.07.15
Posted by 구차니