### Build and Run Example with CMake Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/c-interface.md Instructions for building and running the C example using CMake. Ensure the ccap library is built and installed first. ```bash mkdir build cd build cmake .. make ./ccap_c_example ``` -------------------------------- ### Build iOS Example with CocoaPods Source: https://github.com/wysaid/cameracapture/blob/main/examples/README.md Build the iOS example for ccap using CocoaPods. Navigate to the examples directory, install pods, and open the workspace in Xcode. ```bash cd ccap/examples pod install open *.xcworkspace ``` -------------------------------- ### Build and Run Desktop Examples Source: https://github.com/wysaid/cameracapture/blob/main/README.md Instructions for building and running the C++ and C examples for desktop platforms using CMake. Ensure examples are enabled during CMake configuration. ```bash mkdir build && cd build cmake .. -DCCAP_BUILD_EXAMPLES=ON cmake --build . # Run examples ./0-print_camera ./1-minimal_example # Run the pure C variants (if you built C examples) ./0-print_camera_c ./1-minimal_example_c ``` -------------------------------- ### C Interface Example: Capture and Get Frame Info Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/implementation-details.md Demonstrates using the C interface to create a provider, open a camera, grab a frame, retrieve its information, and release resources. ```c #include int main() { CcapProvider* provider = ccap_provider_create(); if (ccap_provider_open(provider, NULL, true)) { CcapVideoFrame* frame = ccap_provider_grab(provider, 3000); if (frame) { CcapVideoFrameInfo info; ccap_video_frame_get_info(frame, &info); printf("Captured: %dx%d\n", info.width, info.height); ccap_video_frame_release(frame); } } ccap_provider_destroy(provider); return 0; } ``` -------------------------------- ### Build Example Programs Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Enables the compilation of example programs, which demonstrate various functionalities of the CameraCapture library, including basic capture, callbacks, and video playback. Requires GLFW for preview examples. ```bash cmake -B build -DCCAP_BUILD_EXAMPLES=ON ``` -------------------------------- ### CLI Tool: Real-time Preview Source: https://github.com/wysaid/cameracapture/blob/main/README.md Starts a real-time preview window for the default camera using the ccap CLI tool. Requires GLFW to be installed. ```bash # Real-time preview (requires GLFW) ./ccap --preview ``` -------------------------------- ### Build Desktop Examples with CMake Source: https://github.com/wysaid/cameracapture/blob/main/examples/README.md Build desktop examples for ccap using CMake. Ensure you are in the ccap directory and have created a build directory. ```bash cd ccap mkdir build && cd build cmake .. -DCCAP_BUILD_EXAMPLES=ON cmake --build . ``` -------------------------------- ### Verify Installation Source: https://github.com/wysaid/cameracapture/blob/main/BUILD_AND_INSTALL.md Tests the installation of the ccap library for standard, universal binary, and custom installation paths. ```bash # Test standard installation ./scripts/test_installation.sh # Test universal binary installation ./scripts/test_installation.sh build/universal # Test custom installation path ./scripts/test_installation.sh /path/to/install ``` -------------------------------- ### Run ccap-rs Examples Source: https://github.com/wysaid/cameracapture/blob/main/bindings/rust/README.md Commands to run the included examples for listing cameras, minimal capture, and capture using grab or callback modes. ```bash # List available cameras and their info cargo run --example print_camera # Minimal capture example cargo run --example minimal_example # Capture frames using grab mode cargo run --example capture_grab # Capture frames using callback mode cargo run --example capture_callback ``` -------------------------------- ### Minimal ccap-rs Example Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/rust-bindings.md A basic example demonstrating how to initialize the provider, find available camera devices, open a device, grab a frame, and print frame information. Ensure the 'ccap' crate is imported. ```rust use ccap::{Provider, Result}; fn main() -> Result<()> { let mut provider = Provider::new()?; let devices = provider.find_device_names()?; if let Some(device) = devices.first() { provider.open_device(Some(device), true)?; if let Some(frame) = provider.grab_frame(3000)? { let info = frame.info()?; println!("{}x{} {:?}", info.width, info.height, info.pixel_format); } } Ok(()) } ``` -------------------------------- ### Custom CMake Configuration and Build Source: https://github.com/wysaid/cameracapture/blob/main/BUILD_AND_INSTALL.md Use this command to configure a custom CMake build, specifying release type, installation prefix, and enabling example builds. It then proceeds to build and install the project. ```bash # Custom CMake configuration mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCCAP_BUILD_EXAMPLES=ON make -j$(nproc) make install ``` -------------------------------- ### Standard Build and Installation Source: https://github.com/wysaid/cameracapture/blob/main/BUILD_AND_INSTALL.md Builds and installs the ccap library to a specified directory. Supports specifying the installation path and build type (e.g., Release). ```bash # Build and install to ./install directory ./scripts/build_and_install.sh # Specify installation directory ./scripts/build_and_install.sh /path/to/install # Specify build type ./scripts/build_and_install.sh /path/to/install Release ``` -------------------------------- ### Include Examples CMake Script Source: https://github.com/wysaid/cameracapture/blob/main/CMakeLists.txt Includes the CMake script for building examples if CCAP_BUILD_EXAMPLES is enabled. ```cmake if (CCAP_BUILD_EXAMPLES) include(examples/desktop.cmake) endif () ``` -------------------------------- ### Install GLFW Library and Targets Source: https://github.com/wysaid/cameracapture/blob/main/examples/desktop/glfw/src/CMakeLists.txt Installs the GLFW library, targets, and related files to the specified installation directories. Use when GLFW_INSTALL is enabled to install the built library. ```cmake if (GLFW_INSTALL) install(TARGETS glfw EXPORT glfwTargets RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() ``` -------------------------------- ### Start Camera Capture Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/c-interface.md Initiates the camera capture process. Returns an error if the capture cannot be started. ```c if (!ccap_provider_start(provider)) { printf("Failed to start camera\n"); return -1; } ``` -------------------------------- ### Build ccap from Source Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Clone the repository, navigate to the directory, and run the build and install script. ```bash git clone https://github.com/wysaid/CameraCapture.git cd CameraCapture ./scripts/build_and_install.sh ``` -------------------------------- ### Custom Installation Prefix Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Installs the built project to a custom location using CMake's install command and prefix option. ```bash cmake -B build -DCCAP_INSTALL=ON cmake --build build sudo cmake --install build --prefix /usr/local ``` ```bash cmake --install build --prefix $HOME/.local ``` -------------------------------- ### Enable and Configure Installation Source: https://github.com/wysaid/cameracapture/blob/main/CMakeLists.txt Enables the installation of the ccap library, headers, and CMake configuration files. Sets installation directories based on standard CMake variables. ```cmake if (CCAP_INSTALL) message(STATUS "ccap: Installing enabled") # Include necessary modules for installation include(GNUInstallDirs) include(CMakePackageConfigHelpers) # Set installation directories set(CCAP_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) set(CCAP_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) set(CCAP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/ccap) # Install the library install(TARGETS ccap EXPORT ccapTargets LIBRARY DESTINATION ${CCAP_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CCAP_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CCAP_INSTALL_INCLUDEDIR} ) # Install header files install(DIRECTORY include/ DESTINATION ${CCAP_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" ) # Create and install package configuration files configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccapConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/ccapConfig.cmake" INSTALL_DESTINATION ${CCAP_INSTALL_CMAKEDIR} PATH_VARS CCAP_INSTALL_INCLUDEDIR CCAP_INSTALL_LIBDIR ) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/ccapConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) # Install the configuration files install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ccapConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/ccapConfigVersion.cmake" DESTINATION ${CCAP_INSTALL_CMAKEDIR} ) # Install the targets file install(EXPORT ccapTargets FILE ccapTargets.cmake NAMESPACE ccap:: DESTINATION ${CCAP_INSTALL_CMAKEDIR} ) # Generate pkg-config file configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccap.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/ccap.pc" @ONLY ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ccap.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" ) message(STATUS "ccap: Installation paths:") message(STATUS " Libraries: ${CMAKE_INSTALL_PREFIX}/${CCAP_INSTALL_LIBDIR}") message(STATUS " Headers: ${CMAKE_INSTALL_PREFIX}/${CCAP_INSTALL_INCLUDEDIR}") message(STATUS " CMake: ${CMAKE_INSTALL_PREFIX}/${CCAP_INSTALL_CMAKEDIR}") endif () ``` -------------------------------- ### First Publish Example Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/PUBLISHING.md Publish the ccap skill bundle for the initial release to ClawHub. Ensure the path points to the skill folder. ```bash clawhub publish ./skills/ccap \ --slug ccap \ --name "ccap" \ --version 0.1.0 \ --tags latest \ --changelog "Initial ClawHub release" ``` -------------------------------- ### Enable Installation Targets Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Enables CMake installation targets, which will install headers, libraries, and configuration files to standard locations when `cmake --install` is run. The default is ON for the root project and OFF for subdirectories. ```bash cmake -B build -DCCAP_INSTALL=ON ``` -------------------------------- ### Clean Build Source: https://github.com/wysaid/cameracapture/blob/main/BUILD_AND_INSTALL.md This command cleans all build and installation files generated by the build process. It is useful for starting a fresh build. ```bash # Clean all build files git clean -fdx build/ git clean -fdx install/ ``` -------------------------------- ### Install ccap from Source (Library-focused) Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/references/install.md Installs ccap using a repository shortcut, primarily for library usage. ```bash ./scripts/build_and_install.sh ``` -------------------------------- ### Install ClawHub CLI Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/PUBLISHING.md Install the ClawHub command-line interface globally using npm. ```bash npm i -g clawhub ``` -------------------------------- ### Preview camera feed in real-time Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cli.md Starts a real-time preview of the camera feed. Requires GLFW library. ```bash ccap -d 0 --preview ``` -------------------------------- ### Install GLFW Headers and Config Files Source: https://github.com/wysaid/cameracapture/blob/main/examples/desktop/glfw/CMakeLists.txt Installs GLFW header files and CMake configuration files to the appropriate system directories. Ensure GLFW_INSTALL is enabled for this to take effect. ```cmake if (GLFW_INSTALL) install(DIRECTORY include/GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h) install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake" "${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake" DESTINATION "${GLFW_CONFIG_PATH}") install(EXPORT glfwTargets FILE glfw3Targets.cmake EXPORT_LINK_INTERFACE_LIBRARIES DESTINATION "${GLFW_CONFIG_PATH}") install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") # Only generate this target if no higher-level project already has if (NOT TARGET uninstall) configure_file(CMake/cmake_uninstall.cmake.in cmake_uninstall.cmake IMMEDIATE @ONLY) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${GLFW_BINARY_DIR}/cmake_uninstall.cmake") set_target_properties(uninstall PROPERTIES FOLDER "GLFW3") endif() endif() ``` -------------------------------- ### Development Build (All Features) Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Enables all development-related features, including examples, tests, and the command-line interface, for comprehensive testing and development. ```bash cmake -B build \ -DCCAP_BUILD_EXAMPLES=ON \ -DCCAP_BUILD_TESTS=ON \ -DCCAP_BUILD_CLI=ON cmake --build build ``` -------------------------------- ### Video File Playback Example (Windows/macOS) Source: https://github.com/wysaid/cameracapture/blob/main/README.md Shows how to open and play video files using the ccap::Provider API, similar to camera capture. Not supported on Linux. ```cpp #include ccap::Provider provider; // Open video file - same API as camera if (provider.open("/path/to/video.mp4", true)) { // Check if in file mode if (provider.isFileMode()) { // Get video properties double duration = provider.get(ccap::PropertyName::Duration); double frameCount = provider.get(ccap::PropertyName::FrameCount); double frameRate = provider.get(ccap::PropertyName::FrameRate); // Set playback speed (1.0 = normal speed) provider.set(ccap::PropertyName::PlaybackSpeed, 1.0); // Seek to specific time provider.set(ccap::PropertyName::CurrentTime, 10.0); // Seek to 10 seconds } // Grab frames - same API as camera while (auto frame = provider.grab(3000)) { // Process frame... } } ``` -------------------------------- ### Basic C++ Camera Capture Example Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Demonstrates how to initialize the ccap provider, list available cameras, open a device, and capture a single frame. Includes basic error checking for opening the device and grabbing the frame. ```cpp #include int main() { ccap::Provider provider; // List available cameras auto devices = provider.findDeviceNames(); for (size_t i = 0; i < devices.size(); ++i) { printf("[%zu] %s\n", i, devices[i].c_str()); } // Open and start camera if (provider.open("", true)) { auto frame = provider.grab(3000); if (frame) { printf("Captured: %dx%d\n", frame->width, frame->height); } } return 0; } ``` -------------------------------- ### Video Frame-by-Frame Analysis Setup Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/video-memory-management.md Provides a setup for performing frame-by-frame analysis on a video dataset. It utilizes default ccap settings (fast reading, backpressure, bounded memory) which are ideal for ensuring all frames are processed safely and efficiently, regardless of file size. ```cpp ccap::Provider provider; provider.open("dataset.mp4", true); // Default settings are perfect: // - PlaybackSpeed=0: Fast reading // - Backpressure: No drops // - Bounded memory: Safe for large files while (auto frame = provider.grab(1000)) { // Every frame is guaranteed to be processed processFrame(frame); } ``` -------------------------------- ### Build and Install ccap CLI from Source Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/references/install.md Explicitly builds and installs the ccap CLI binary from source. Requires CMake. ```bash cmake -B build -DCCAP_BUILD_CLI=ON -DCCAP_INSTALL=ON cmake --build build cmake --install build ccap --version ``` -------------------------------- ### Pure C Camera Capture Example Source: https://github.com/wysaid/cameracapture/blob/main/docs/index.html This C snippet shows how to initialize the provider, find devices, open a camera, and capture a video frame. It uses the C API for camera capture. ```c #include #include int main() { CcapProvider* provider = ccap_provider_create(); if (!provider) return -1; // Find available devices CcapDeviceNamesList deviceList; if (ccap_provider_find_device_names_list(provider, &deviceList)) { printf("Found %zu camera(s)\n", deviceList.deviceCount); } // Open and capture if (ccap_provider_open(provider, NULL, true)) { CcapVideoFrame* frame = ccap_provider_grab(provider, 3000); if (frame) { CcapVideoFrameInfo info; ccap_video_frame_get_info(frame, &info); printf("Captured: %dx%d\n", info.width, info.height); ccap_video_frame_release(frame); } } ccap_provider_destroy(provider); return 0; } ``` -------------------------------- ### Video Writing Example (Windows/macOS) Source: https://github.com/wysaid/cameracapture/blob/main/README.md Demonstrates how to write video frames to a file using ccap::VideoWriter. Requires CCAP_ENABLE_VIDEO_WRITER=ON. ```cpp #include #include ccap::Provider provider; ccap::VideoWriter writer; if (provider.open("", true)) { ccap::WriterConfig cfg; cfg.width = 1280; cfg.height = 720; cfg.frameRate = 30.0; cfg.codec = ccap::VideoCodec::H264; cfg.container = ccap::VideoFormat::MP4; if (writer.open("camera_record.mp4", cfg)) { while (auto frame = provider.grab(3000)) { // timestampNs == 0 means auto timestamp generation from frameRate. writer.writeFrame(*frame, 0); } writer.close(); } } ``` -------------------------------- ### Install ccap using Homebrew on macOS Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/references/install.md Use this when the host is macOS and the task only needs the CLI. It taps the repository and installs ccap. ```bash brew tap wysaid/ccap brew install ccap ccap --version ``` -------------------------------- ### Windows Camera Backend Override Example Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cli.md Demonstrates setting a Windows camera backend override via environment variable before launching the CLI. This ensures a specific backend (e.g., msmf) is used. ```bash export CCAP_WINDOWS_BACKEND=msmf ./ccap --list-devices ``` -------------------------------- ### Preview camera feed only Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cli.md Starts a real-time preview of the camera feed without saving any frames. ```bash ccap -d 0 --preview-only ``` -------------------------------- ### Manual Compilation on Linux Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/c-interface.md Command to compile the C example manually on Linux, specifying include and library paths. ```bash gcc -std=c99 ccap_c_example.c -o ccap_c_example \ -I/path/to/ccap/include \ -L/path/to/ccap/lib -lccap \ -lpthread ``` -------------------------------- ### ccap::Provider::start Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Starts the camera capture stream. This should be called after opening the device if autoStart was false. ```APIDOC ## ccap::Provider::start ### Description Starts the camera capture stream. This should be called after opening the device if autoStart was false. ### Method `bool start();` ### Parameters None ### Response - `bool`: Returns true if the camera started successfully, false otherwise. ``` -------------------------------- ### Linux Camera Access Setup Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/implementation-details.md Grant user access to video devices on Linux by adding the user to the 'video' group and verify device availability. ```bash # Add user to video group sudo usermod -a -G video $USER # Verify devices ls -l /dev/video* ``` -------------------------------- ### Install ccap with Homebrew on macOS Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Tap the ccap repository and install the ccap package using Homebrew. ```bash brew tap wysaid/ccap brew install ccap ``` -------------------------------- ### Check Existing ccap Installation Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/references/install.md Verify if ccap is already installed and check its version. ```bash command -v ccap ccap --version ``` -------------------------------- ### Windows Build and Install Source: https://github.com/wysaid/cameracapture/blob/main/BUILD_AND_INSTALL.md Builds and installs the ccap library on Windows using Git Bash. It automatically generates both Debug and Release versions of the library files. ```bash # Windows build and install (run in Git Bash) # Automatically builds both Debug and Release versions ./scripts/build_and_install.sh # Specify installation directory ./scripts/build_and_install.sh /path/to/install # Windows will automatically generate: # - ccap.lib (Release version) # - ccapd.lib (Debug version with 'd' suffix) ``` -------------------------------- ### Production Build (Optimized) Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Configures the project for production with optimizations, disabled logging, and installation targets enabled. ```bash cmake -B build \ -DCMAKE_BUILD_TYPE=Release \ -DCCAP_NO_LOG=ON \ -DCCAP_INSTALL=ON cmake --build build cmake --install build --prefix /usr/local ``` -------------------------------- ### C Interface: Basic Camera Capture Source: https://github.com/wysaid/cameracapture/blob/main/README.md Demonstrates creating a provider, finding devices, opening a camera, setting format, starting capture, grabbing a frame, and releasing resources using the pure C interface. ```c #include #include int main() { // Create provider CcapProvider* provider = ccap_provider_create(); if (!provider) return -1; // Find available devices CcapDeviceNamesList deviceList; if (ccap_provider_find_device_names_list(provider, &deviceList)) { printf("Found %zu camera device(s):\n", deviceList.deviceCount); for (size_t i = 0; i < deviceList.deviceCount; i++) { printf(" %zu: %s\n", i, deviceList.deviceNames[i]); } } // Open default camera if (ccap_provider_open(provider, NULL, false)) { // Set output format ccap_provider_set_property(provider, CCAP_PROPERTY_PIXEL_FORMAT_OUTPUT, CCAP_PIXEL_FORMAT_BGR24); // Start capture if (ccap_provider_start(provider)) { // Grab a frame CcapVideoFrame* frame = ccap_provider_grab(provider, 3000); if (frame) { CcapVideoFrameInfo frameInfo; if (ccap_video_frame_get_info(frame, &frameInfo)) { // Get pixel format string char formatStr[64]; ccap_pixel_format_to_string(frameInfo.pixelFormat, formatStr, sizeof(formatStr)); printf("Captured: %dx%d, format=%s\n", frameInfo.width, frameInfo.height, formatStr); } ccap_video_frame_release(frame); } } ccap_provider_stop(provider); ccap_provider_close(provider); } ccap_provider_destroy(provider); return 0; } ``` -------------------------------- ### Manual Compilation on macOS Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/c-interface.md Command to compile the C example manually on macOS, specifying include and library paths. ```bash gcc -std=c99 ccap_c_example.c -o ccap_c_example \ -I/path/to/ccap/include \ -L/path/to/ccap/lib -lccap \ -framework Foundation -framework AVFoundation \ -framework CoreMedia -framework CoreVideo ``` -------------------------------- ### Update Example Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/PUBLISHING.md Publish an updated version of the ccap skill bundle to ClawHub. Increment the version and update the changelog accordingly. ```bash clawhub publish ./skills/ccap \ --slug ccap \ --name "ccap" \ --version 0.1.1 \ --tags latest \ --changelog "Refine installation guidance and command examples" ``` -------------------------------- ### Verify Camera Capture CLI Version Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/SKILL.md Check the installed version of the Camera Capture CLI. ```bash ccap --version ``` -------------------------------- ### CMake Development Build Configuration Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/implementation-details.md Configures a CMake build for development with examples and tests enabled. ```bash cmake -B build -DCCAP_BUILD_EXAMPLES=ON -DCCAP_BUILD_TESTS=ON ``` -------------------------------- ### Preview camera feed with timeout Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cli.md Starts a camera preview that will automatically exit after a specified duration. ```bash ccap -d 0 --preview --timeout 60 ``` -------------------------------- ### Enabling GLFW Preview Mode in CLI Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Enables the GLFW-based preview mode for the command-line interface. Requires the GLFW library to be installed. ```bash -DCCAP_BUILD_CLI=ON -DCCAP_CLI_WITH_GLFW=ON ``` -------------------------------- ### Available Build and Test Scripts Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/implementation-details.md A collection of scripts for building, installing, formatting, testing, and managing versions of the cameracapture project. Includes scripts for cross-compilation and architecture-specific optimizations. ```bash # Build and install ./scripts/build_and_install.sh # Format all source files ./scripts/format_all.sh # Run all tests ./scripts/run_tests.sh # Run specific test category ./scripts/run_tests.sh functional ./scripts/run_tests.sh performance ./scripts/run_tests.sh shuffle # Update version across all files ./scripts/update_version.sh 1.2.3 # Test architecture-specific optimizations ./scripts/test_arch.sh # x86_64 AVX2 ./scripts/verify_neon.sh # ARM64 NEON # Cross-compilation ./scripts/build_arm64.sh # ARM64 Linux ./scripts/build_arm64_win.sh # ARM64 Windows ./scripts/build_macos_universal.sh # Universal macOS binary ``` -------------------------------- ### Custom Development Settings with dev.cmake Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Example of overriding default CMake settings by creating a custom cmake/dev.cmake file. ```cmake # cmake/dev.cmake - Custom development settings # Force shared library set(CCAP_BUILD_SHARED ON CACHE BOOL "" FORCE) # Enable all features set(CCAP_BUILD_EXAMPLES ON CACHE BOOL "" FORCE) set(CCAP_BUILD_TESTS ON CACHE BOOL "" FORCE) set(CCAP_BUILD_CLI ON CACHE BOOL "" FORCE) ``` -------------------------------- ### Basic C++ Code Example for ccap Source: https://github.com/wysaid/cameracapture/blob/main/BUILD_AND_INSTALL.md Demonstrates basic usage of the ccap library in C++. It shows how to initialize a provider, find available camera devices, open the default camera, and capture a single frame. ```cpp #include #include int main() { ccap::Provider provider; // Get available device list auto deviceNames = provider.findDeviceNames(); std::cout << "Found " << deviceNames.size() << " camera device(s)" << std::endl; // Print device names for (size_t i = 0; i < deviceNames.size(); ++i) { std::cout << " " << i << ": " << deviceNames[i] << std::endl; } // Open default camera if (provider.open()) { std::cout << "Camera opened successfully!" << std::endl; // Capture one frame if (auto frame = provider.grab(1000)) { std::cout << "Frame captured: " << frame->width << "x" << frame->height << std::endl; } } return 0; } ``` -------------------------------- ### Rust Camera Capture Example Source: https://github.com/wysaid/cameracapture/blob/main/docs/index.html This Rust snippet demonstrates camera capture using the ccap-rs crate. It includes adding the dependency to Cargo.toml and basic usage for finding devices and capturing frames. ```rust // Cargo.toml: // ccap = { package = "ccap-rs", version = "" } use ccap::{Provider, Result}; fn main() -> Result<()> { let mut provider = Provider::new()?; let devices = provider.find_device_names()?; println!("Found {} camera(s)", devices.len()); if let Some(first) = devices.get(0) { provider.open_device(Some(first), true)?; if let Some(frame) = provider.grab_frame(3000)? { let info = frame.info()?; println!("Captured: {}x{}", info.width, info.height); } } Ok(()) } ``` -------------------------------- ### Manual Compilation on Windows (MSVC) Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/c-interface.md Command to compile the C example manually on Windows using MSVC, specifying include and library paths. ```cmd cl ccap_c_example.c /I"path\to\ccap\include" \ /link "path\to\ccap\lib\ccap.lib" ole32.lib oleaut32.lib uuid.lib ``` -------------------------------- ### Build ccap CLI with Preview Support (GLFW) Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cli.md Build the ccap CLI tool with real-time preview capabilities enabled using GLFW. This requires GLFW to be installed on the system. ```bash cmake -B build -DCCAP_BUILD_CLI=ON -DCCAP_CLI_WITH_GLFW=ON cmake --build build ``` -------------------------------- ### Install ccap using Homebrew Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/SKILL.md Use this command to install ccap on macOS via Homebrew. Ensure Homebrew is installed and configured. ```bash brew install wysaid/ccap/ccap ``` -------------------------------- ### C API Error Handling Example Source: https://github.com/wysaid/cameracapture/blob/main/README.md Demonstrates how to set up a global error callback function to receive error notifications from the ccap library. This is useful for handling camera device errors gracefully. ```c // Error codes typedef enum { CCAP_ERROR_NONE = 0, CCAP_ERROR_NO_DEVICE_FOUND = 0x1001, // No camera device found CCAP_ERROR_INVALID_DEVICE = 0x1002, // Invalid device name or index CCAP_ERROR_DEVICE_OPEN_FAILED = 0x1003, // Camera open failed CCAP_ERROR_DEVICE_START_FAILED = 0x1004, // Camera start failed CCAP_ERROR_UNSUPPORTED_RESOLUTION = 0x2001, // Unsupported resolution CCAP_ERROR_UNSUPPORTED_PIXEL_FORMAT = 0x2002, // Unsupported pixel format CCAP_ERROR_FRAME_CAPTURE_TIMEOUT = 0x3001, // Frame capture timeout CCAP_ERROR_FRAME_CAPTURE_FAILED = 0x3002, // Frame capture failed // More error codes... } CcapErrorCode; // Error callback function typedef void (*CcapErrorCallback)(CcapErrorCode errorCode, const char* errorDescription, void* userData); // Set error callback bool ccap_set_error_callback(CcapErrorCallback callback, void* userData); // Get error description const char* ccap_error_code_to_string(CcapErrorCode errorCode); // Usage example void error_callback(CcapErrorCode errorCode, const char* errorDescription, void* userData) { printf("Camera Error - Code: %d, Description: %s\n", (int)errorCode, errorDescription); } int main() { // Set error callback to receive error notifications ccap_set_error_callback(error_callback, NULL); CcapProvider* provider = ccap_provider_create(); if (!ccap_provider_open_by_index(provider, 0, true)) { printf("Failed to open camera\n"); // Error callback will also be called } ccap_provider_destroy(provider); return 0; } ``` -------------------------------- ### Get Device Info (JSON) Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/references/commands.md Retrieves detailed information about a specific device, identified by its index, in JSON format. Expect capability data upon successful opening, or a structured error if the device cannot be opened. ```bash ccap --device-info 0 --json ``` -------------------------------- ### Default Build (Static Library) Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Configures and builds the project using default settings, resulting in a static library. ```bash cmake -B build cmake --build build ``` -------------------------------- ### Start and Stop Camera Capture Source: https://github.com/wysaid/cameracapture/blob/main/README.md Control the camera capture process. Start capture to begin receiving frames and stop it when no longer needed. ```c // Capture control bool ccap_provider_start(CcapProvider* provider); void ccap_provider_stop(CcapProvider* provider); bool ccap_provider_is_started(CcapProvider* provider); ``` -------------------------------- ### Basic Camera Capture in Rust Source: https://github.com/wysaid/cameracapture/blob/main/bindings/rust/README.md Demonstrates initializing the camera provider, finding available devices, opening the first camera, and capturing a single frame with basic error handling. This snippet shows how to access frame information and raw data. ```rust use ccap::{Provider, Result}; fn main() -> Result<()> { // Create a camera provider let mut provider = Provider::new()?; // Find available cameras let devices = provider.find_device_names()?; println!("Found {} cameras:", devices.len()); for (i, device) in devices.iter().enumerate() { println!(" [{}] {}", i, device); } // Open the first camera if !devices.is_empty() { provider.open_device(Some(&devices[0]), true)?; println!("Camera opened successfully!"); // Capture a frame (with 3 second timeout) if let Some(frame) = provider.grab_frame(3000)? { let info = frame.info()?; println!("Captured frame: {}x{}, format: {:?}", info.width, info.height, info.pixel_format); // Access frame data let data = frame.data()?; println!("Frame data size: {} bytes", data.len()); } } Ok(()) } ``` -------------------------------- ### CMake Find Package for ccap Source: https://github.com/wysaid/cameracapture/blob/main/docs/index.html This CMake snippet demonstrates how to find an installed ccap package and link it to your application. This is useful if ccap has been installed system-wide or via a package manager. ```cmake find_package(ccap REQUIRED) target_link_libraries(your_app ccap::ccap) ``` -------------------------------- ### Troubleshooting: No devices found Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cli.md Command to list devices and expected output when no camera devices are found. Provides common solutions for this issue. ```bash ccap --list-devices # Returns: No camera devices found ``` -------------------------------- ### Ccap Error Callback Usage Example Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/c-interface.md Example demonstrating how to set an error callback function and use it within the main application flow. The callback is invoked when errors occur during camera operations. ```c // Error callback function void error_callback(CcapErrorCode errorCode, const char* errorDescription, void* userData) { printf("Camera Error - Code: %d, Description: %s\n", (int)errorCode, errorDescription); } int main() { // Set error callback ccap_set_error_callback(error_callback, NULL); CcapProvider* provider = ccap_provider_create(); // Perform camera operations, callback will be called if errors occur if (!ccap_provider_open_by_index(provider, 0, true)) { printf("Failed to open camera\n"); } ccap_provider_destroy(provider); return 0; } ``` -------------------------------- ### Capture Control Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/c-interface.md Functions for starting, stopping, and checking the capture status. ```APIDOC ## Capture Control ### `ccap_provider_start(CcapProvider* provider)` #### Description Starts the video capture process. #### Parameters * **provider** (`CcapProvider*`) - Required - Pointer to the provider object. ### `ccap_provider_stop(CcapProvider* provider)` #### Description Stops the video capture process. #### Parameters * **provider** (`CcapProvider*`) - Required - Pointer to the provider object. ### `ccap_provider_is_started(CcapProvider* provider)` #### Description Checks if the video capture is currently active. #### Parameters * **provider** (`CcapProvider*`) - Required - Pointer to the provider object. #### Returns `bool` - `true` if capturing, `false` otherwise. ``` -------------------------------- ### Property Configuration Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/c-interface.md Functions for setting and getting properties of the capture provider. ```APIDOC ## Property Configuration ### `ccap_provider_set_property(CcapProvider* provider, CcapPropertyName property, const void* value)` #### Description Sets a specific property for the capture provider. #### Parameters * **provider** (`CcapProvider*`) - Required - Pointer to the provider object. * **property** (`CcapPropertyName`) - Required - The name of the property to set. * **value** (`const void*`) - Required - Pointer to the value of the property. ### `ccap_provider_get_property(CcapProvider* provider, CcapPropertyName property, void* value)` #### Description Gets the current value of a specific property from the capture provider. #### Parameters * **provider** (`CcapProvider*`) - Required - Pointer to the provider object. * **property** (`CcapPropertyName`) - Required - The name of the property to get. * **value** (`void*`) - Required - Pointer to a buffer where the property value will be stored. ``` -------------------------------- ### List Devices (Text) Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/references/commands.md Use this command as a fallback to list available camera devices and receive the output in a human-readable text format. ```bash ccap --list-devices ``` -------------------------------- ### Verify Hardware Acceleration (ARM64) Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/implementation-details.md Command to verify the usage of NEON SIMD for hardware acceleration on an ARM64 system. ```bash ./scripts/verify_neon.sh ``` -------------------------------- ### Create Feature Branch Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/implementation-details.md Start a new feature development by creating a new Git branch from the current branch. ```bash git checkout -b feature/my-feature ``` -------------------------------- ### ccap::PropertyName::FrameCount Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Gets the total number of frames in the video file. Only applicable when in file playback mode. ```APIDOC ## ccap::PropertyName::FrameCount ### Description Gets the total number of frames in the video file. Only applicable when in file playback mode. ### Usage ```cpp // Get total frame count double frameCount = provider.get(ccap::PropertyName::FrameCount); ``` ### Parameters None ### Response - `double`: The total number of frames in the video file. ``` -------------------------------- ### Troubleshooting: Format not supported Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cli.md Command to test an unsupported format and the resulting error message. Recommends using a supported format. ```bash ccap -d 0 --format xyz # Error: Unknown format ``` -------------------------------- ### ccap::PropertyName::Duration Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Gets the total duration of the video file in seconds. Only applicable when in file playback mode. ```APIDOC ## ccap::PropertyName::Duration ### Description Gets the total duration of the video file in seconds. Only applicable when in file playback mode. ### Usage ```cpp // Get video duration double duration = provider.get(ccap::PropertyName::Duration); ``` ### Parameters None ### Response - `double`: The duration of the video file in seconds. ``` -------------------------------- ### Build Universal Version Source: https://github.com/wysaid/cameracapture/blob/main/scripts/README.md Build the universal version (supporting both ARM64 and x86_64 architectures) in Release mode. This is recommended for release builds. ```bash # Build universal version (both architectures) /path/to/ccap/scripts/build.sh universal Release ``` -------------------------------- ### Configure Target Include Directories Source: https://github.com/wysaid/cameracapture/blob/main/CMakeLists.txt Sets public include directories for the target library, distinguishing between build and install interfaces. ```cmake target_include_directories(ccap PUBLIC $ $ ) ``` -------------------------------- ### Basic C++ Camera Capture Usage Source: https://github.com/wysaid/cameracapture/blob/main/README.md Demonstrates listing available cameras, opening the default camera, and capturing a single frame with a timeout. The captured frame's properties (dimensions, format) are then printed. ```cpp #include int main() { ccap::Provider provider; // List available cameras auto devices = provider.findDeviceNames(); for (size_t i = 0; i < devices.size(); ++i) { printf("[%zu] %s\n", i, devices[i].c_str()); } // Open and start camera if (provider.open("", true)) { // Empty string = default camera auto frame = provider.grab(3000); // 3 second timeout if (frame) { printf("Captured: %dx%d, %s format\n", frame->width, frame->height, ccap::pixelFormatToString(frame->pixelFormat).data()); } } return 0; } ``` -------------------------------- ### Build Native CameraCapture Library (Debug) Source: https://github.com/wysaid/cameracapture/blob/main/bindings/rust/README.md Manual steps to build the native CameraCapture C/C++ library in Debug mode using CMake and Make. This is required for the 'static-link' feature. ```bash mkdir -p build/Debug cd build/Debug cmake ../.. -DCMAKE_BUILD_TYPE=Debug make -j$(nproc) ``` -------------------------------- ### Property Configuration Source: https://github.com/wysaid/cameracapture/blob/main/README.md Functions for setting and getting various camera properties, including resolution, frame rate, and pixel format. ```APIDOC ## Property Configuration ### Set Property - **`bool ccap_provider_set_property(CcapProvider* provider, CcapPropertyName prop, double value);`**: Sets a specific camera property. `prop` is the property identifier and `value` is its new setting. ### Get Property - **`double ccap_provider_get_property(CcapProvider* provider, CcapPropertyName prop);`**: Retrieves the current value of a specific camera property. ### Main Properties Enum (`CcapPropertyName`) - **`CCAP_PROPERTY_WIDTH`**: Sets or gets the frame width. - **`CCAP_PROPERTY_HEIGHT`**: Sets or gets the frame height. - **`CCAP_PROPERTY_FRAME_RATE`**: Sets or gets the desired frame rate. - **`CCAP_PROPERTY_PIXEL_FORMAT_OUTPUT`**: Sets or gets the output pixel format. - **`CCAP_PROPERTY_FRAME_ORIENTATION`**: Sets or gets the frame orientation. ### Pixel Formats Enum (`CcapPixelFormat`) - **`CCAP_PIXEL_FORMAT_UNKNOWN`**: Unknown pixel format. - **`CCAP_PIXEL_FORMAT_NV12`**: NV12 format. - **`CCAP_PIXEL_FORMAT_NV12F`**: NV12 format with a flag. - **`CCAP_PIXEL_FORMAT_RGB24`**: RGB 24-bit format. - **`CCAP_PIXEL_FORMAT_BGR24`**: BGR 24-bit format. - **`CCAP_PIXEL_FORMAT_RGBA32`**: RGBA 32-bit format. - **`CCAP_PIXEL_FORMAT_BGRA32`**: BGRA 32-bit format. ``` -------------------------------- ### Build Native Architecture Version Source: https://github.com/wysaid/cameracapture/blob/main/scripts/README.md Use this command to build the native architecture version of the project in Debug mode. This is the recommended command for daily development. ```bash # Build native architecture version (recommended) /path/to/ccap/scripts/build.sh native Debug ``` -------------------------------- ### Build ccap CLI from Source (CLI-focused) Source: https://github.com/wysaid/cameracapture/blob/main/skills/ccap/references/install.md Builds the ccap CLI binary from source without installing it globally. Requires CMake. ```bash cmake -B build -DCCAP_BUILD_CLI=ON cmake --build build ./build/ccap --version ``` -------------------------------- ### CLI Tool: List Available Cameras Source: https://github.com/wysaid/cameracapture/blob/main/README.md Lists all available camera devices using the ccap command-line tool. ```bash # List available cameras ./ccap --list-devices ``` -------------------------------- ### ccap::PropertyName::Height Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Sets or gets the height of the video frame. Used for configuring camera resolution or video file properties. ```APIDOC ## ccap::PropertyName::Height ### Description Sets or gets the height of the video frame. Used for configuring camera resolution or video file properties. ### Usage ```cpp // Set height provider.set(ccap::PropertyName::Height, 1080); // Get height int height = static_cast(provider.get(ccap::PropertyName::Height)); ``` ### Parameters - `value` (double): The desired height in pixels. ``` -------------------------------- ### ccap::PropertyName::Width Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Sets or gets the width of the video frame. Used for configuring camera resolution or video file properties. ```APIDOC ## ccap::PropertyName::Width ### Description Sets or gets the width of the video frame. Used for configuring camera resolution or video file properties. ### Usage ```cpp // Set width provider.set(ccap::PropertyName::Width, 1920); // Get width int width = static_cast(provider.get(ccap::PropertyName::Width)); ``` ### Parameters - `value` (double): The desired width in pixels. ``` -------------------------------- ### Troubleshooting: Permission denied on Linux Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cli.md Command to add a user to the 'video' group on Linux to resolve permission issues for camera devices. Requires logging out and back in. ```bash # Add your user to the video group sudo usermod -a -G video $USER # Then log out and back in ``` -------------------------------- ### Setting CMAKE_PREFIX_PATH for Package Discovery Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/cmake-options.md Configures the CMAKE_PREFIX_PATH to help CMake find installed packages, resolving 'Cannot find ccap package' errors. ```bash cmake -B build -DCMAKE_PREFIX_PATH=/usr/local ``` -------------------------------- ### Video File Playback with ccap Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Illustrates how to use ccap to play video files by opening them like cameras. Includes checking file mode, retrieving video properties like duration and frame count, setting playback speed, seeking to a specific time, and grabbing frames. ```cpp #include ccap::Provider provider; // Open video file - same API as camera if (provider.open("/path/to/video.mp4", true)) { // Check if in file mode if (provider.isFileMode()) { // Get video properties double duration = provider.get(ccap::PropertyName::Duration); double frameCount = provider.get(ccap::PropertyName::FrameCount); // Set playback speed (1.0 = normal speed) provider.set(ccap::PropertyName::PlaybackSpeed, 1.0); // Seek to specific time provider.set(ccap::PropertyName::CurrentTime, 10.0); } // Grab frames - same API as camera while (auto frame = provider.grab(3000)) { // Process frame... } } ``` -------------------------------- ### ccap::Provider::open Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Opens a specified camera device for capture. It can open by device name or index and optionally start the camera automatically. ```APIDOC ## ccap::Provider::open ### Description Opens a specified camera device for capture. It can open by device name or index and optionally start the camera automatically. ### Method `bool open(std::string_view deviceName, bool autoStart = true);` `bool open(int deviceIndex, bool autoStart = true);` ### Parameters - `deviceName` (std::string_view): The name of the device to open. - `deviceIndex` (int): The index of the device to open. - `autoStart` (bool): If true, the camera will start automatically after opening. ### Response - `bool`: Returns true if the device was opened successfully, false otherwise. ``` -------------------------------- ### Get Actual Video Codec Used by Writer Source: https://github.com/wysaid/cameracapture/blob/main/README.md Retrieve the actual video codec that the CcapVideoWriter is using. This can be useful for confirming settings or for further processing. ```c CcapVideoCodec ccap_video_writer_actual_codec(const CcapVideoWriter* writer); ``` -------------------------------- ### ccap::PropertyName::PixelFormatOutput Source: https://github.com/wysaid/cameracapture/blob/main/docs/content/documentation.md Sets or gets the desired output pixel format after hardware-accelerated conversion. This determines the format of the `VideoFrame` returned by `grab()`. ```APIDOC ## ccap::PropertyName::PixelFormatOutput ### Description Sets or gets the desired output pixel format after hardware-accelerated conversion. This determines the format of the `VideoFrame` returned by `grab()`. ### Usage ```cpp // Set output format to BGR24 provider.set(ccap::PropertyName::PixelFormatOutput, static_cast(ccap::PixelFormat::BGR24)); // Get output format ccap::PixelFormat format = static_cast(provider.get(ccap::PropertyName::PixelFormatOutput)); ``` ### Parameters - `value` (double): The desired output pixel format, cast from `ccap::PixelFormat` enum. ```