Skip to content

Commit 0984f61

Browse files
committed
update readme, add ir threshold
1 parent 4779c94 commit 0984f61

File tree

7 files changed

+34
-76
lines changed

7 files changed

+34
-76
lines changed

README.md

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# IR Retro-reflective Marker Tracking with Intel RealSense
22

3-
[![GitHub release](https://img.shields.io/github/release/stytim/RealSense-ToolTracker.svg?style=flat-square)](https://github.com/stytim/RealSense-ToolTracker/releases)
3+
[![GitHub release](https://img.shields.io/github/release/stytim/AzureKinect-ToolTracker.svg?style=flat-square)](https://github.com/stytim/AzureKinect-ToolTracker/releases)
44

5-
This project leverages the versatility of Intel RealSense cameras, enabling high-quality tracking of passive IR sphere markers without the need for large and expensive equipment like NDI trackers.
5+
This project leverages the versatility of Microsoft Azure Kinect cameras, enabling high-quality tracking of passive IR sphere markers without the need for large and expensive equipment like NDI trackers.
66

77
<p align="center">
88
<img width="80%" src="image/overview.gif">
99
</p>
1010

1111

1212
## Project Highlights
13-
* **Compact and Cost-Effective**: Break free from the constraints of traditional tracking systems. Our project utilizes the small, affordable Intel RealSense camera for efficient tracking.
13+
* **Compact and Cost-Effective**: Break free from the constraints of traditional tracking systems. Our project utilizes the small, affordable Azure Kinect camera for efficient tracking.
1414
* **Versatile and User-Friendly**: Efficiently handle simultaneous tracking of various markers. Enjoy robust features such as multiple marker tracking, occlusion resistance, and support for various marker types and sizes.
1515
* **Smooth and Stable Tracking**: Integrate Kalman and low-pass filters for stable tracking.
1616
* **Enhanced Communication and Compatibility**: Utilize UDP messaging for transmitting tracking results and support for NDI .rom files
1717
* **Simple Calibration**: A simple marker array calibration is provided if the marker configuration is not known beforehand
18-
* **Cross-Platform Availability**: Works across Linux, Windows, and MacOS environments.
18+
* **Cross-Platform Availability**: Works across Linux and Windows environments.
1919

2020
## Installation
2121
**Quick Start with Precompiled Binary (Windows):** Download the latest precompiled binary from our releases section for immediate use.
@@ -24,14 +24,14 @@ This project leverages the versatility of Intel RealSense cameras, enabling high
2424

2525
## Prerequisites
2626

27-
* Intel RealSense SDK (MacOS users, please refer to the FAQ for installation guidance)
27+
* Azure Kinect SDK
2828
* OpenCV 4
2929
* CMake
3030

3131
## Building
3232
Ensure all the prerequisites are installed before proceeding with the build process.
3333

34-
### For Linux and MacOS:
34+
### For Linux:
3535

3636
```bash
3737
mkdir build && cd build
@@ -49,32 +49,10 @@ Note: I have only tested this build process with Visual Studio 2022.
4949
```bash
5050
./ir-tracking-app
5151
```
52-
### For MacOS
53-
Due to certain permissions and security features in MacOS, you might need to run the application with elevated privileges.
52+
### Offline Processing from Recording
5453
```bash
55-
sudo ./ir-tracking-app
54+
./ir-tracking-app -i path_to_recording.mkv
5655
```
57-
## RealSense Camera Modification: Adding a Light Diffuser
58-
59-
The laser projector of the RealSense camera emits a sharp, focused IR dot pattern. While this is generally beneficial for depth sensing, it is not ideal for doing thresholding on IR stream to find retroreflective surfaces.
60-
61-
Therefore, a crucial modification is required: the addition of a physical light diffuser filter in front of the camera's laser projector. This softens the laser dot pattern in the IR stream.
62-
<table>
63-
<tr>
64-
<td align="center" width="45%">
65-
<img src="image/light_diffuser.jpg" alt="RealSense with light diffuser"><br>
66-
RealSense with Light Diffuser
67-
</td>
68-
<td align="center" width="45%">
69-
<img src="image/no_diffuser.png" alt="Without Light Diffuser"><br>
70-
Without Light Diffuser, the visible dot pattern can interfere with detecting retroreflective surfaces in the IR stream.
71-
</td>
72-
</tr>
73-
</table>
74-
</p>
75-
76-
77-
7856

7957
## Usage Guide
8058

@@ -101,7 +79,14 @@ Upon launching the RealSense Tool Tracker, the application will attempt to load
10179
* Transmission Rate: Confirm the "Frequency" of tracking updates to suit your needs.
10280
* UDP Enable: Ensure the "UDP" checkbox is selected to activate network transmission.
10381

104-
### 3. Start Tracking
82+
### 3. Save Tracking Results Locally to CSV
83+
84+
* Rate: Input the "Frequency" of writing the CSV file.
85+
* Duration: Input how long in seconds to save the file
86+
* Save Location: Click "Save To" to select the name and location for the CSV file.
87+
* Record Enable: Ensure the "Record" checkbox is selected to activate recording to file.
88+
89+
### 4. Start Tracking
10590
* Initiate Tracking: With all parameters set, initiate tracking by clicking "Start Tracking."
10691
* Real-Time Adjustments: You can tweak the Tracking Parameters in real-time to adapt to varying conditions.
10792
- Infrared Sensitivity: Adjust the "IR Threshold" to optimize infrared tracking sensitivity.
@@ -115,17 +100,9 @@ A sample Python and a C# Unity scripts is provided for receiving and processing
115100
Contributions are welcome! When submitting a pull request, please include a description of your improvements and reference any relevant issue numbers.
116101

117102
## Frequently Asked Questions (FAQs)
118-
### Can I use Azure Kinect Cameras for this project?
103+
### Can I use Intel RealSense Cameras for this project?
119104

120-
Currently, Azure Kinect Cameras are not supported due to an issue with marker overexposure, which affects the retrieval of valid depth values. For more insights, please refer to the discussion on [Azure-Kinect-Sensor-SDK Issue #1349](https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/1349)
121-
122-
### I'm encountering issues while installing the Intel RealSense SDK on MacOS. What should I do?
123-
124-
Installation issues on MacOS can be tricky due to Intel dropping support for newer MacOS and Mac with Apple silicon. I recommend this comprehensive guide on [setting up Intel RealSense on MacOS](https://lightbuzz.com/realsense-macos/).
125-
126-
### What are the future plans for this project?
127-
128-
My next big goal is to implement support for a multi-camera setup, enabling marker tracking over larger areas. However, as this project is a part-time endeavor, progress might be gradual. Stay tuned for updates!
105+
Yes, please refer to the [RealSense Tool Tracker](https://github.com/stytim/RealSense-ToolTracker)
129106

130107

131108
## License and Citation
@@ -157,9 +134,8 @@ A significant portion of the tracking code is adapted from Andreas Keller's work
157134
```
158135

159136

160-
161137
<picture>
162-
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=stytim/RealSense-ToolTracker&type=Date&theme=dark" />
163-
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=stytim/RealSense-ToolTracker&type=Date" />
164-
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=stytim/RealSense-ToolTracker&type=Date" />
138+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=stytim/Azure-ToolTracker&type=Date&theme=dark" />
139+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=stytim/AzureKinect-ToolTracker&type=Date" />
140+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=stytim/AzureKinect-ToolTracker&type=Date" />
165141
</picture>

include/IRToolTrack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class IRToolTracker
102102

103103
IRToolTracking* m_pRealSenseToolTracking;
104104

105-
uchar m_Threshold = 100;
105+
ushort m_Threshold = 3000;
106106
int m_MinSize = 10;
107107
int m_MaxSize = 180;
108108

include/IRToolTracking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class IRToolTracking {
120120

121121
// int frame_width = 848;
122122
// int frame_height = 480;
123-
int irThreshold = 100;
123+
int irThreshold = 3000;
124124
int minSize = 10;
125125
int maxSize = 280;
126126

include/ViewerWindow.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ class ViewerWindow {
7979
std::string recordedFile = "";
8080

8181
IRToolTracking tracker;
82-
int irThreshold = 100;
83-
int laserPower = 300;
84-
int minlasPower = 0;
85-
int maxlasPower = 360;
82+
int irThreshold = 3000;
83+
8684
int minPixelSize = 10;
8785
int maxPixelSize = 300;
8886
bool isToolAdded = false;

src/IRToolTrack.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,21 +620,16 @@ void IRToolTracker::regionGrowing(const cv::Mat &depthImage, const std::vector<c
620620
}
621621

622622
bool IRToolTracker::ProcessFrame(AHATFrame* rawFrame, ProcessedAHATFrame &result) {
623-
uchar lowerLimit = m_Threshold;
624-
uchar upperLimit = lowerLimit + 1;// 256 * 20;
623+
//uchar lowerLimit = m_Threshold;
625624
int minSize = m_MinSize, maxSize = m_MaxSize;
626625
cv::Mat labels, stats, centroids;
627626
std::vector<float> irToolCenters;
628627

629-
// rawFrame->cvAbImage.forEach<uchar>(
630-
// [&](uchar& ir, const int* position) -> void {
631-
// ir = (std::clamp(ir, lowerLimit, upperLimit) - lowerLimit) / (upperLimit - lowerLimit)*255;
632-
// }
633-
// );
628+
std::cout << m_Threshold << std::endl;
634629

635630
// Threshold IR image
636631
cv::Mat thresholdedIR;
637-
cv::threshold(rawFrame->cvAbImage, thresholdedIR, 3000, 255, cv::THRESH_BINARY);
632+
cv::threshold(rawFrame->cvAbImage, thresholdedIR, m_Threshold, 255, cv::THRESH_BINARY);
638633

639634
thresholdedIR.convertTo(rawFrame->cvAbImage, CV_8UC1);
640635

src/IRToolTracking.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ void IRToolTracking::initialize(int index, int width, int height) {
5858
return;
5959
}
6060

61-
62-
// SetThreshold(irThreshold);
63-
// SetMinMaxSize(minSize, maxSize);
64-
6561
if (K4A_RESULT_SUCCEEDED != k4a_device_open(index, &device))
6662
{
6763
std::cout << "Failed to open device" << std::endl;
@@ -80,6 +76,9 @@ void IRToolTracking::initialize(int index, int width, int height) {
8076
return;
8177
}
8278

79+
irThreshold = 3000;
80+
SetThreshold(irThreshold);
81+
8382
Terminated = false;
8483
}
8584

src/ViewerWindow.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,6 @@ void ViewerWindow::Render() {
686686
else
687687
{
688688
tracker.initialize(selectedDeviceIndex, 848, 480);
689-
tracker.getLaserPower(laserPower, minlasPower, maxlasPower);
690689
}
691690
tracker.StartToolTracking();
692691
irThreshold = tracker.GetThreshold();
@@ -708,20 +707,11 @@ void ViewerWindow::Render() {
708707
// Add a slider for setting the IR threshold
709708
ImGui::SetNextWindowPos(ImVec2(400, 20), ImGuiCond_FirstUseEver);
710709
ImGui::Begin("IR Threshold Control", nullptr, overlayFlags);
711-
// if not on Mac
712-
#if !defined(__APPLE__)
713-
{
714-
if(ImGui::SliderInt("Laser Power", &laserPower, minlasPower, maxlasPower))
715-
{
716-
tracker.setLaserPower(laserPower);
717-
}
718-
}
719-
#endif
720-
if(ImGui::SliderInt("IR Threshold", &irThreshold, 0, 255))
710+
if(ImGui::SliderInt("IR Threshold", &irThreshold, 2000, 4000))
721711
{
722712
tracker.SetThreshold(irThreshold);
723713
}
724-
ImGui::SetNextItemWidth(100);
714+
/* ImGui::SetNextItemWidth(100);
725715
if (ImGui::InputInt("Min Px", &minPixelSize))
726716
{
727717
tracker.SetMinMaxSize(minPixelSize, maxPixelSize);
@@ -731,7 +721,7 @@ void ViewerWindow::Render() {
731721
if (ImGui::InputInt("Max Px", &maxPixelSize))
732722
{
733723
tracker.SetMinMaxSize(minPixelSize, maxPixelSize);
734-
}
724+
}*/
735725
ImGui::End();
736726

737727
// Checkbox for enabling UDP

0 commit comments

Comments
 (0)