diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c961c03 --- /dev/null +++ b/.gitignore @@ -0,0 +1,117 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Build directories +build/ +cmake-build-*/ +out/ +bin/ +lib/ + +# CMake +CMakeCache.txt +CMakeFiles/ +CMakeScripts/ +Testing/ +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +# IDEs +## CLion +.idea/ +cmake-build-debug/ +cmake-build-release/ + +## Visual Studio Code +.vscode/ +*.code-workspace + +## Visual Studio +.vs/ +*.user +*.userosscache +*.sln.docstates +*.suo +*.sdf +*.opensdf +*.VC.db +*.VC.opendb + +## Xcode +*.xcodeproj +*.xcworkspace +xcuserdata/ + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# OS files +## macOS +.DS_Store +.AppleDouble +.LSOverride + +## Linux +*~ +.directory +.Trash-* + +## Windows +Thumbs.db +ehthumbs.db +Desktop.ini +$RECYCLE.BIN/ + +# Backup files +*.bak +*.swp +*.swo +*~ + +# Conan +conaninfo.txt +conanbuildinfo.cmake +conan.lock + +# vcpkg +vcpkg_installed/ + +# Package managers +node_modules/ diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c81d1b..894a850 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,4 +30,12 @@ set_target_properties(vizionStreamer PROPERTIES BUILD_RPATH "${VIZIONSDK_LIB_DIR}" INSTALL_RPATH "${VIZIONSDK_LIB_DIR}" ) + +# Copy VxConfig.conf to build directory on every build +add_custom_command(TARGET vizionStreamer POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/config/VxConfig.conf + ${CMAKE_BINARY_DIR}/VxConfig.conf + COMMENT "Copying VxConfig.conf to build directory" +) # -------------------------------------------------------- diff --git a/config/VxConfig.conf b/config/VxConfig.conf new file mode 100644 index 0000000..9ae5cb8 --- /dev/null +++ b/config/VxConfig.conf @@ -0,0 +1,8 @@ +[VCI] +products = VCI + +[VCS] +products = VCS,VLI,UVC-VLS + +[TEVS] +products = TEVS \ No newline at end of file diff --git a/main.cpp b/main.cpp index 1122971..ada045f 100644 --- a/main.cpp +++ b/main.cpp @@ -5,6 +5,66 @@ // TIP To Run code, press or click the icon in the gutter. int main() { + // List available cameras + std::vector devList; + int deviceCount = VxDiscoverCameraDevices(devList); + + if (deviceCount == 0) { + std::cout << "No cameras found" << std::endl; + return -1; + } + + std::cout << "Found " << deviceCount << " camera(s):" << std::endl; + for (size_t i = 0; i < devList.size(); i++) { + std::cout << "[" << i << "] " << devList[i] << std::endl; + } + + // Open camera + auto cam = VxInitialCameraDevice(0); + if (!cam || VxOpen(cam) != 0) { + std::cout << "Failed to initialize/open camera" << std::endl; + return -1; + } + + // Get and set format + std::vector fmtList; + if (VxGetFormatList(cam, fmtList) != 0) { + std::cout << "Failed to get format list" << std::endl; + VxClose(cam); + return -1; + } + + if (VxSetFormat(cam, fmtList[0]) != 0) { + std::cout << "Failed to set format" << std::endl; + VxClose(cam); + return -1; + } + + // Start streaming + if (VxStartStreaming(cam) != 0) { + std::cout << "Failed to start streaming" << std::endl; + VxClose(cam); + return -1; + } + + // Capture 5 frames + std::shared_ptr buffer(new uint8_t[fmtList[0].width * fmtList[0].height * 3]); + int dataSize; + + for (int i = 0; i < 5; i++) { + VX_CAPTURE_RESULT result = VxGetImage(cam, buffer.get(), &dataSize, 1000); + if (result == VX_CAPTURE_RESULT::VX_SUCCESS) { + std::cout << "Successfully captured frame " << i + 1 << " of size: " << dataSize << " bytes" << std::endl; + } else { + std::cout << "Failed to capture frame " << i + 1 << std::endl; + break; + } + } + + // Cleanup + VxStopStreaming(cam); + VxClose(cam); + return 0; // TIP See CLion help at jetbrains.com/help/clion/. Also, you can try interactive lessons for CLion by selecting 'Help | Learn IDE Features' from the main menu. } \ No newline at end of file