'프로그램 사용'에 해당되는 글 2314건

  1. 2025.05.07 kinect 1.x, 2.x color <-> depth mapping
  2. 2025.05.06 kinect v2 잘못된 깊이 맵 맵핑
  3. 2025.05.05 libfreenect2 rgb / depth 매핑 소스코드 분석
  4. 2025.05.01 kinect rgb - depth mapping
  5. 2025.04.18 mosquitto qos
  6. 2025.04.18 ssh-copy-id
  7. 2025.04.16 blender + kinect
  8. 2025.04.15 kinect 깊이 정밀도
  9. 2025.04.08 ros...?
  10. 2025.04.07 ros urdf

링크와는 다르게 내용상으로는 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' 카테고리의 다른 글

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
kinect 깊이 정밀도  (0) 2025.04.15
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 구차니

ROS 보다보니 QoS 이야기가 나와서 조사

그런데 정작 찾아봐도 적용방법이 잘 안보인다.

conf 파일에서는 max_qos와 topic patern에 추가하는 정도?

 

topic pattern [[[ out | in | both ] qos-level] local-prefix remote-prefix]

max_qos value
Limit the QoS value allowed for clients connecting to this listener. Defaults to 2, which means any QoS can be used. Set to 0 or 1 to limit to those QoS values. This makes use of an MQTT v5 feature to notify clients of the limitation. MQTT v3.1.1 clients will not be aware of the limitation. Clients publishing to this listener with a too-high QoS will be disconnected.

Not reloaded on reload signal.

[링크 : https://mosquitto.org/man/mosquitto-conf-5.html]

 

QoS는 0,1,2가 존재한다. 그런데 기본값이 멀까..?

Quality of Service
MQTT defines three levels of Quality of Service (QoS). The QoS defines how hard the broker/client will try to ensure that a message is received. Messages may be sent at any QoS level, and clients may attempt to subscribe to topics at any QoS level. This means that the client chooses the maximum QoS it will receive. For example, if a message is published at QoS 2 and a client is subscribed with QoS 0, the message will be delivered to that client with QoS 0. If a second client is also subscribed to the same topic, but with QoS 2, then it will receive the same message but with QoS 2. For a second example, if a client is subscribed with QoS 2 and a message is published on QoS 0, the client will receive it on QoS 0.

Higher levels of QoS are more reliable, but involve higher latency and have higher bandwidth requirements.

0: The broker/client will deliver the message once, with no confirmation.
1: The broker/client will deliver the message at least once, with confirmation required.
2: The broker/client will deliver the message exactly once by using a four step handshake.

[링크 : https://mosquitto.org/man/mqtt-7.html]

 

초당 32000 메시지라.. 느린거 걱정안해도 될 것 같기도 하고?

[링크 : https://hel-p.tistory.com/18]

 

[링크 : https://dalkomit.tistory.com/111]

[링크 : https://www.ibm.com/docs/ko/ibm-mq/9.2.x?topic=concepts-qualities-service-provided-by-mqtt-client]

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

mosquitto for windows 계정추가  (0) 2025.02.18
mosquitto service for windows  (0) 2025.02.18
CC2531 zigbee - mqtt  (0) 2025.01.07
ubuntu MQTT(mosquito)  (0) 2024.05.23
mosquitto - MQTT broker  (0) 2019.05.15
Posted by 구차니

와!! 이런 개꿀 명령어가?!?!?

직접 키 복사해서 넣어도 되지만 한번만 접속하면 알아서 복사해주니 개 꿀!

 

ssh-copy-id [-i [identity_file]] [user@]machine

[링크 : https://linux.die.net/man/1/ssh-copy-id]

 

[링크 : https://itzone.tistory.com/694]

Posted by 구차니
프로그램 사용/Blender2025. 4. 16. 14:00

kinect 로 촬영한 골격 정보를 저장해두고 그걸 blender에서 armature에 붙여서 움직여 주는 듯?

[링크 : https://www.youtube.com/watch?v=djzzgSiEa04]

 

다만 아쉽게도(?) kinect sdk를 사용하는거라 윈도우에서만 가능.

그런데 블렌더가.. 키 프레임 애니메이션일텐데 live capture 를 live render 할 수 있나?

Advantages

  • No installation;
  • Works with live capture or pre-recorded data (through Kinect Studio);
  • Supports multiple skeletons;
  • Straightforward use. Does not require setting additional parameters.

Download (latest release)

Windows x64 binary

System Requirements

[링크 : https://marcojrfurtado.github.io/KinectAnimationStudio/]

 

+

2025.06.30

[링크  : https://github.com/Kvendy-an/KinectMocap4Blender]

[링크 : https://www.reddit.com/r/blender/comments/1kcwxml/real_time_motion_capture_using_xbox_one_kinect/]

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

blender 휠 에뮬레이트 하기  (0) 2025.05.18
blender 강좌  (0) 2025.01.01
blender render - cycle, eevee  (0) 2024.08.30
blender shader editor (4.2 bloom)  (0) 2024.08.29
blender set origin  (0) 2024.08.23
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 구차니
프로그램 사용/ros2025. 4. 8. 20:50

ros 1, ros 2 책을 대충 봤는데

MQTT를 이용해서 노드별로 데이터를 주고받는 것에 치중하고

어떻게 실행한다는 많아도 어떻게 파일을 구성해서 작동시킨다는 내용이 얼마 없어서

정작 도움이 안되었다는게 함정..

rviz 쪽을 따로 봐야하나?

 

[링크 : https://product.kyobobook.co.kr/detail/S000028165712] ROS 1

[링크 : https://www.yes24.com/Product/Goods/102949767] ROS 2

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

ros2 with kinect v2 일단 실패  (0) 2025.05.21
ros2 uses concol  (0) 2025.05.20
ros 2 install on ubuntu 24.04, rviz  (2) 2025.05.17
ros urdf  (0) 2025.04.07
ROS rviz  (0) 2023.12.21
Posted by 구차니
프로그램 사용/ros2025. 4. 7. 19:48

ROS를 쓰는건 별거(?) 아니고

내가 쓰려는 로봇에 맞춰서 이 파일을 만들어 ros 에서 쓰게 하는게 핵심일 듯?

 

URDF(Unified Robot Description Format)

[링크 : https://with-rl.tistory.com/m/entry/URDF를-이용한-간단한-로봇-만들기-1]

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

ros2 with kinect v2 일단 실패  (0) 2025.05.21
ros2 uses concol  (0) 2025.05.20
ros 2 install on ubuntu 24.04, rviz  (2) 2025.05.17
ros...?  (0) 2025.04.08
ROS rviz  (0) 2023.12.21
Posted by 구차니