The Vision application is a sophisticated device management system designed to interface with Kinect v2 sensors using the libfreenect2
library. This application offers functionalities such as listing available devices, opening specific devices, and selecting devices for use. It incorporates a logging system to facilitate debugging and provide informative output throughout the device management process.
- Device Management: Automatically detect, list, and manage Kinect devices.
- Singleton Design Pattern: Ensures a single instance of the
DeviceManager
. - Configurable Logging: Adjustable logging levels for better debugging and monitoring.
- Error Handling: Robust status reporting for operations.
- Installation
- Usage
- Architecture
- File Descriptions
- Classes and Functions
- Logging Levels
- Error Handling
- Testing
- Contributing
- License
Ensure you have the following installed:
- CMake
- libfreenect2
- A C++ compiler (e.g., g++, clang)
-
Clone the Repository:
git clone https://github.com/yourusername/vision.git cd vision
-
Install Dependencies:
Follow the installation instructions for
libfreenect2
on your system. -
Build the Project:
mkdir build cd build cmake .. make
-
Run the Application:
./vision
Upon execution, the Vision application will automatically enumerate connected Kinect devices and log their information to the console. An example output would be:
[Info] [Vision] Console Logger initialized.
[Info] [Vision] Listing Devices
[Info] [Vision] Device 0: SERIAL_NUMBER_1
[Info] [Vision] Device 1: SERIAL_NUMBER_2
[Info] [Vision] Vision Finished.
The Vision application consists of several key components:
- Device Management: Manages the lifecycle and interactions with Kinect devices.
- Logging System: Logs important events and statuses to the console.
- Status Reporting: Provides feedback on the outcomes of operations.
+------------------+ +-------------------+
| | | |
| DeviceManager |<-------->| ConsoleLogger |
| | | |
+------------------+ +-------------------+
|
v
+------------------+
| |
| Kinect Device |
| |
+------------------+
- config.h: Contains configuration settings and application constants.
- device.h: Defines the
Device
struct for holding device attributes. - device_manager.h: Declares the
DeviceManager
class for device management. - console_logger.h: Defines the
ConsoleLogger
class for logging. - logger.h: Abstract base class for logging utilities.
- status.h: Contains definitions for operation statuses and result handling.
- main.cpp: The entry point of the application, orchestrating the device management workflow.
Handles the detection and management of Kinect devices.
-
static DeviceManager* getInstance()
- Returns the singleton instance of the
DeviceManager
.
- Returns the singleton instance of the
-
Result listDevices(const std::vector<Device>& devices) const
- Lists and logs all available devices.
-
Result openDevices(const std::vector<Device>& devices)
- Opens specified devices for usage (implementation pending).
-
Result selectDevices(const std::vector<int>& ids)
- Selects devices by their IDs and logs their serial numbers.
Implements logging functionalities to the console.
-
static ConsoleLogger* getInstance()
- Returns the singleton instance of the
ConsoleLogger
.
- Returns the singleton instance of the
-
void log(Level level, const std::string& message)
- Logs messages at the specified logging level.
Abstract class defining the logging interface.
virtual void log(Level level, const std::string &message) = 0
- Abstract logging method to be implemented by derived classes.
An enumeration for operation statuses:
- Success
- Error
- InvalidParam
- NotFound
The application supports several logging levels to control output verbosity:
- None: No logging.
- Error: Logs error messages.
- Warning: Logs warnings.
- Info: Logs general information.
- Debug: Logs detailed debug information.
The application implements a structured error handling mechanism using the Result
struct, which includes status codes and messages to aid in troubleshooting.
Unit tests are included for critical components of the application. To run the tests, use:
make test
Ensure your environment is set up correctly to support testing.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a clear description of your changes.