Opencv2.3 read the depth information and color image of Kinect

Source: Internet
Author: User

Opencv2.3 read the depth information and color image of Kinect

By http://blog.csdn.net/moc062066

Opencv2.3 can directly read the depth information and color image of Kinect, but it is required when compiling opencv.Note thatFor more information, see here.

// Moc062066 // 20111021 /// * # include <opencv2/CORE/core. HPP> // basic opencv structures (CV: mat, scalar) # include <opencv2/highgui. HPP> // opencv window I/ousing namespace CV; */# include <opencv2/opencv. HPP> using namespace CV; # include <iostream> using namespace STD; static void help () {cout <"Usage: Hit any key to quit! "<Endl <" Kinect opening... "<Endl;} int main (INT argc, char ** argv) {help (); videocapture capture (cv_cap_openni); If (! Capture. isopened () {cerr <"no device has derected! "<Endl; Return-1 ;}cout <" width "<capture. get (cv_cap_prop_frame_width) <Endl <"heigth" <capture. get (cv_cap_prop_frame_height) <Endl; STD: String rgb_wnd = "RGB camera"; STD: String depth_wnd = "depth camera"; namedwindow (rgb_wnd, cv_window_autosize ); namedwindow (depth_wnd, cv_window_autosize); For (;) {mat depthmap; MAT rgbimage; capture. grab (); // depthmap XYZ in meters (cv_32fc3). XYZ is the space location capture of each point in the retrieved vertex cloud. retrieve (depthmap, cv_cap_openni_point_cloud_map); // color image (cv_8uc3) capture. retrieve (rgbimage, token); imshow (rgb_wnd, rgbimage); imshow (depth_wnd, depthmap); If (waitkey (30)> = 0) {break ;}} return 0 ;}

Result:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.