├── releasenot.txt
├── .gitignore
├── VirtualDevice
├── VirtualDevice.h
├── VirtualDevice.vcxproj
└── VirtualDevice.cpp
├── README.md
├── PathSetting.props
├── LICENSE
├── Samples
├── BasicSample
│ ├── main.cpp
│ └── BasicSample.vcxproj
├── NiTESample
│ ├── VirtualDeviceHelper.h
│ ├── main.cpp
│ └── NiTESample.vcxproj
├── ExistedDeviceSample
│ ├── main.cpp
│ └── ExistedDevice.vcxproj
└── DepthToWorldSample
│ ├── OpenGLCamera.h
│ ├── DepthToWorld.vcxproj
│ └── main.cpp
├── VirtualDevice.sln
└── APACHE_LICENSE_2
/releasenot.txt:
--------------------------------------------------------------------------------
1 | 2014/05/20
2 | Fix the bug that no properties of VideoStream when recording
3 |
4 | 2013/11/008
5 | First release
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 |
6 | # Compiled Dynamic libraries
7 | *.so
8 | *.dylib
9 |
10 | # Compiled Static libraries
11 | *.lai
12 | *.la
13 | *.a
14 |
--------------------------------------------------------------------------------
/VirtualDevice/VirtualDevice.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This is a simple example to show how to use the virtual device.
3 | * This sample will open an existed real device, read the depth frame with listener,
4 | * then copy to the virtual device.
5 | *
6 | * http://viml.nchc.org.tw/home/
7 | */
8 |
9 | #pragma once
10 |
11 | // definition of customized property
12 | #define GET_VIRTUAL_STREAM_IMAGE 100000
13 | #define SET_VIRTUAL_STREAM_IMAGE 100001
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | VirtualDeviceForOpenNI2
2 | =======================
3 |
4 | This project provides a virtual device module for OpenNI 2, which accept user feed any depth, color images.
5 |
6 | With the virtual device, you can:
7 |
8 | 1. create a device in OpenNI, to get the data from sensor with their own SDK
9 | 2. modify the raw data from sensor, let middleware libraries use modified data
10 |
11 |
12 | The pre-compiled binary for windows could be downlod: https://github.com/VIML/VirtualDeviceForOpenNI2/releases
13 |
14 |
15 | ---
16 |
17 | This is a free and Open Source project for non-commercial use.
18 | Please email us a note, if you use this product in any area of work.
19 | For commercial use, please contact us for further information.
20 |
21 | email: viml.nchc@gmail.com / charlie.nchc@gmail.com
22 |
23 | ---
24 |
25 | - More information: https://github.com/VIML/VirtualDeviceForOpenNI2/wiki
26 | - Chinese version: http://viml.nchc.org.tw/blog/paper_info.php?CLASS_ID=1&SUB_ID=1&PAPER_ID=509
27 |
--------------------------------------------------------------------------------
/PathSetting.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(SolutionDir)\..\OpenNI2Dev\
6 | $(SolutionDir)\..\..\OpenCV-2.4.6.0\opencv
7 | opencv_core246d.lib;opencv_highgui246d.lib;opencv_imgproc246d.lib
8 | opencv_core246.lib;opencv_highgui246.lib;opencv_imgproc246.lib
9 |
10 |
11 |
12 | $(OpenNI_SDK_Path)
13 |
14 |
15 | $(OpenCV_Path)
16 |
17 |
18 | $(OpenCV_Libs_Debug)
19 |
20 |
21 | $(OpenCV_Libs_Release)
22 |
23 |
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2013, Visualization and Interactive Media Laboratory
2 |
3 | This product includes software developed at the "Visualization and
4 | Interactive Media Laboratory" at the "National Center for High-performance
5 | Computing" in Taiwan.
6 |
7 | Our website: http://viml.nchc.org.tw/
8 |
9 | Licensed under the Apache License, Version 2.0 (the "License"); you may not
10 | use this file except in compliance with the License. You may obtain a copy
11 | of the License at
12 |
13 | http://www.apache.org/licenses/LICENSE-2.0
14 |
15 | Unless required by applicable law or agreed to in writing, software
16 | distributed under the License is distributed on an "AS IS" BASIS,
17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | See the License for the specific language governing permissions and
19 | limitations under the License.
20 |
21 | Please email us a note, if you use this product in any area of work.
22 | Your feedback will give us the incentives to improve and evolve.
23 |
24 | For commercial use, please contact us for further information.
25 |
26 | email: viml.nchc@gmail.com / charlie.nchc@gmail.com
27 |
--------------------------------------------------------------------------------
/Samples/BasicSample/main.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * This is a basic example to show how to use the virtual device.
3 | * This sample will create a new thread to generate dummy frame, and read by OpenNI API.
4 | *
5 | * http://viml.nchc.org.tw/home/
6 | */
7 |
8 | // STL Header
9 | #include
10 |
11 | // OpenNI Header
12 | #include
13 |
14 | // XnLib in OpenNI Source Code, use for threading
15 | #include "XnLib.h"
16 |
17 | // Virtual Device Header
18 | #include "..\..\VirtualDevice\VirtualDevice.h"
19 |
20 | // namespace
21 | using namespace std;
22 | using namespace openni;
23 |
24 | // global object
25 | bool bRunning = true;
26 |
27 | // The function to generate dummy frame
28 | XN_THREAD_PROC GenerateDummyFrame( XN_THREAD_PARAM pThreadParam )
29 | {
30 | VideoStream* pVStream = (VideoStream*)pThreadParam;
31 |
32 | while( bRunning )
33 | {
34 | if( pVStream->isValid() )
35 | {
36 | // get a frame form virtual video stream
37 | OniFrame* pFrame = NULL;
38 | if( pVStream->invoke( GET_VIRTUAL_STREAM_IMAGE, pFrame ) == openni::STATUS_OK )
39 | {
40 | // type casting
41 | DepthPixel* pVirData = reinterpret_cast( pFrame->data );
42 |
43 | // Fill dummy data
44 | for( int y = 0; y < pFrame->height; ++ y )
45 | {
46 | for( int x = 0; x < pFrame->width; ++ x )
47 | {
48 | int idx = x + y * pFrame->width;
49 | pVirData[idx] = 100;
50 | }
51 | }
52 |
53 | // write data to form virtual video stream
54 | pVStream->invoke( SET_VIRTUAL_STREAM_IMAGE, pFrame );
55 |
56 | }
57 | }
58 |
59 | // sleep
60 | xnOSSleep(33);
61 | }
62 |
63 | XN_THREAD_PROC_RETURN(XN_STATUS_OK);
64 | }
65 |
66 | int main( int, char** )
67 | {
68 | #pragma region OpenNI initialize
69 | // Initial OpenNI
70 | if( OpenNI::initialize() != STATUS_OK )
71 | {
72 | cerr << "OpenNI Initial Error: " << OpenNI::getExtendedError() << endl;
73 | return -1;
74 | }
75 |
76 | // Open Virtual Device
77 | Device devVirDevice;
78 | if( devVirDevice.open( "\\OpenNI2\\VirtualDevice\\TEST" ) != STATUS_OK )
79 | {
80 | cerr << "Can't create virtual device: " << OpenNI::getExtendedError() << endl;
81 | return -1;
82 | }
83 |
84 | // create virtual color video stream
85 | VideoStream vsVirDepth;
86 | if( vsVirDepth.create( devVirDevice, SENSOR_DEPTH ) == STATUS_OK )
87 | {
88 | VideoMode mMode;
89 | mMode.setFps( 30 );
90 | mMode.setResolution( 320, 240 );
91 | mMode.setPixelFormat( PIXEL_FORMAT_DEPTH_1_MM );
92 | vsVirDepth.setVideoMode( mMode );
93 | }
94 | else
95 | {
96 | cerr << "Can't create depth stream on device: " << OpenNI::getExtendedError() << endl;
97 | return -1;
98 | }
99 | #pragma endregion
100 |
101 | #pragma region main loop
102 | // start data generate
103 | vsVirDepth.start();
104 |
105 | // create a new thread to generate dummy data
106 | XN_THREAD_HANDLE mThreadHandle;
107 | xnOSCreateThread( GenerateDummyFrame, &vsVirDepth, &mThreadHandle );
108 |
109 | // use for-loop to read 100 frames
110 | for( int i = 0; i < 100; ++ i )
111 | {
112 | VideoFrameRef mFrame;
113 | if( vsVirDepth.readFrame( &mFrame ) == STATUS_OK )
114 | {
115 | const DepthPixel* pData = reinterpret_cast( mFrame.getData() );
116 | cout << pData[ mFrame.getWidth() / 2 + ( mFrame.getHeight() / 2 ) * mFrame.getWidth() ] << endl;
117 | }
118 | }
119 |
120 | // stop data generate
121 | bRunning = false;
122 | vsVirDepth.stop();
123 |
124 | // close device
125 | vsVirDepth.destroy();
126 | devVirDevice.close();
127 |
128 | // shutdown
129 | OpenNI::shutdown();
130 |
131 | #pragma endregion
132 |
133 | return 0;
134 | }
135 |
--------------------------------------------------------------------------------
/Samples/NiTESample/VirtualDeviceHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // STL Header
4 | #include
5 | #include