OUTPUT: 1 2

This project demonstrates real-time video processing using CUDA and OpenCV. It performs the following operations on a video file:

Converts each frame to grayscale using a custom CUDA kernel.

Simulates object detection using a threshold-based CUDA kernel.

Displays the processed frame with "detected" objects highlighted.

๐Ÿ“ธ Sample Use Case Ideal for beginners and intermediate CUDA programmers looking to:

Learn how to interface OpenCV with CUDA.

Implement GPU-accelerated image processing.

Simulate parallel object detection logic.

๐Ÿง  Features ๐Ÿ”„ Real-time frame processing.

๐Ÿงฎ Grayscale conversion using a CUDA kernel.

๐ŸŽฏ Dummy object detection using intensity thresholding.

๐Ÿ–ผ๏ธ Live frame visualization using OpenCV.

๐Ÿงฐ Requirements CUDA Toolkit (>= 10.0 recommended)

OpenCV (>= 4.0)

CMake (optional, if building with CMakeLists)

g++ / nvcc (for compiling CUDA code)

๐Ÿ”ง Setup & Build

  1. Install Dependencies Make sure you have CUDA and OpenCV installed.

For Ubuntu:

bash Copy Edit sudo apt-get install libopencv-dev For Windows:

Install OpenCV via official build or vcpkg

Make sure your system recognizes nvcc (NVIDIA compiler)

  1. Build & Run Option 1: Compile using g++ and nvcc bash Copy Edit nvcc main.cu -o video_processor pkg-config --cflags --libs opencv4 ./video_processor โš ๏ธ Replace opencv4 with opencv if you're using OpenCV 2 or 3.

Option 2: Use CMake (Optional) You can add a CMakeLists.txt if you'd prefer to manage builds easily.

๐Ÿ“‚ Project Structure graphql Copy Edit โ”œโ”€โ”€ main.cu # Main file containing CUDA kernels and OpenCV logic โ”œโ”€โ”€ video.mp4 # Sample video file to test the pipeline โ””โ”€โ”€ README.md # Project documentation ๐Ÿงช How It Works

  1. Grayscale Conversion CUDA kernel computes grayscale using the formula:

ini Copy Edit Gray = 0.299 * R + 0.587 * G + 0.114 * B

  1. Dummy Object Detection A simulated detection logic marks pixels with intensity > 128 as detected.

cpp Copy Edit detectionMap[idx] = (grayImage[idx] > 128) ? 1 : 0;

  1. Visualization Green rectangles are drawn over "detected" areas in each frame using OpenCV.

๐Ÿ“ˆ Performance โœ… GPU acceleration via CUDA ensures fast per-frame computation.

๐Ÿงต Block size: 16 x 16, optimized for typical GPU warp sizes.

๐ŸŽž๏ธ Suitable for real-time video processing on modern GPUs.

๐Ÿง  Future Improvements Replace dummy detection logic with a real ML model.

Add GPU-accelerated video encoding/decoding.

Add frame saving or recording functionality.

๐Ÿ’ก Author Uxair Bachelor of Computer Science | CUDA C | OpenCV Enthusiast Feel free to reach out or contribute!

Built With

Share this project:

Updates