0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

libfreenectを使ったKinect v1の開発②

Last updated at Posted at 2019-02-10

前回の続き.
Depth画像に続きColor画像を表示しようとしたがなぜか画像が切られた状態で表示される問題が発生したのでメモ.

ソースコード

今回は省略した形で掲載.

コールバック関数

void video_cb(freenect_device *dev, void *rgb, uint32_t timestamp)
{
	cv::Mat temp = cv::Mat(480, 640, CV_8UC3, rgb);
	//imshowで正しく表示するためにBGRをBGRに変換
	cv::cvtColor(temp, temp, CV_RGB2BGR);
	//幅を480のままにするとおかしなことになる
    memcpy(color.data, temp.data, 640*(480 + 950));
}

コールバック関数内のmemcpyで640 * 480にすると画像が途中で切れてしまうが, ここを参考にして480に950を足すことでそれを解決できた.
コールバック関数を前回のコードと同様に呼び出せばカラー画像が表示される.

実行結果

  • 失敗例
    color.png

  • 成功例
    color.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?