diff --git a/CMakeLists.txt b/CMakeLists.txt index 23ff4a4..6180536 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,12 @@ endif() # install(DIRECTORY data/ DESTINATION share/text_reader/data) +include_directories(${PROJECT_SOURCE_DIR}/camera_manager.hpp) + # Create the executable -add_executable(text_reader src/main.cpp) +add_executable(text_reader src/main.cpp + src/camera_manager.cpp +) # Copy data files to build directory file(COPY data/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data) diff --git a/src/camera_manager.cpp b/src/camera_manager.cpp new file mode 100644 index 0000000..44da4d3 --- /dev/null +++ b/src/camera_manager.cpp @@ -0,0 +1,11 @@ +#include "camera_manager.hpp" + +CameraManager::CameraManager() { ; } + +void CameraManager::add_rtsp_camera(const std::string& rtsp_address, + int camera_Id) { + RtspCameraConfig current_camera; + current_camera.address = rtsp_address; + current_camera.camera_id = camera_Id; + camera_list.push_back(current_camera); +} diff --git a/src/camera_manager.hpp b/src/camera_manager.hpp new file mode 100644 index 0000000..100a7ef --- /dev/null +++ b/src/camera_manager.hpp @@ -0,0 +1,16 @@ +#include +#include +#include + +struct RtspCameraConfig { + int camera_id; + std::string address; +}; + +class CameraManager { + private: + public: + std::vector camera_list; + CameraManager(); + void add_rtsp_camera(const std::string&, int); +}; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index d491e2f..9f3c83d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,19 +1,23 @@ -#include -#include -#include #include +#include +#include +#include + +#include "camera_manager.hpp" namespace fs = std::filesystem; -int main() { +int load_rtsp_address() { // Path handling works across platforms fs::path data_dir = "/home/user2/temp_code/text_reader/data"; fs::path file_path = data_dir / "example.txt"; - + CameraManager* camera_manager = new CameraManager(); + try { std::ifstream file(file_path); if (!file.is_open()) { - throw std::runtime_error("Failed to open file: " + file_path.string()); + throw std::runtime_error("Failed to open file: " + + file_path.string()); } std::cout << "Contents of '" << file_path << "':\n"; @@ -23,12 +27,14 @@ int main() { int line_number = 1; while (std::getline(file, line)) { std::cout << "Line " << line_number++ << ": " << line << '\n'; + camera_manager->add_rtsp_camera(line, line_number); } - } - catch (const std::exception& e) { + } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << '\n'; return EXIT_FAILURE; } return EXIT_SUCCESS; -} \ No newline at end of file +} + +int main() { load_rtsp_address(); } \ No newline at end of file