This repository contains code and resources for learning and experimenting with OpenCV, a popular computer vision library. The project includes comprehensive functions for video and image processing, deep learning tutorials with CNNs, and sample data for testing and learning.
data/
imgs/
woman.jpg # Original sample image
grayscaled_woman.jpg # Processed grayscale version
HARRISSED_IMAGES/ # Harris corner detection results
MERGED_IMAGES/ # Image merging examples
horizontal/
vertical/
NOISED_IMAGES/ # Salt and pepper noise examples
RECTANGLED_IMAGES/ # Rectangle drawing examples
ROTATED_IMAGES/ # Image rotation examples
opencv-301/, X/, XY/, Y/
SHARPENED_IMAGES/ # Image sharpening results
SHIFTED_IMAGES/ # Image shifting examples
videos/ # Sample video files
src/
image_processing_funcs.py # Core image processing functions
video_processing_funcs.py # Video processing and analysis
computer-vision/
introduction/
advanced_python_concepts.py # Python concepts for CV
deep-learning/
introduction.ipynb # Deep learning introduction
CNN/
CNN.ipynb # Convolutional Neural Networks
main.ipynb # CNN main examples
30-38+CNN.pdf # CNN reference material
pytorch-playground/ # PyTorch experiments
images/ # Additional image resources
logs/ # Processing logs
requirements.txt # Python dependencies
- Basic Operations: Grayscale conversion, image normalization, display and saving
- Geometric Transformations: Image rotation, shifting, merging (horizontal/vertical)
- Drawing Operations: Rectangle drawing and shape overlay
- Filtering & Enhancement: Bilateral filtering, image sharpening
- Noise Processing: Salt and pepper noise addition and removal
- Corner Detection: Harris corner detection, Shi-Tomasi corner detection, sub-pixel corner refinement
- Statistical Analysis: Image histograms, min/max value analysis, mean and standard deviation
- Basic Video Operations: Video information display, frame processing
- Real-time Processing: Live video feed processing with multiple filter options
- Motion Analysis: Background/foreground extraction, KLT (Kanade-Lucas-Tomasi) tracking
- Optical Flow: Dense optical flow computation and visualization
- CNN Tutorials: Comprehensive Convolutional Neural Network examples and theory
- PyTorch Playground: Experimental deep learning implementations
- Educational Materials: Advanced Python concepts for computer vision
- Jupyter Notebooks: Interactive learning environment with step-by-step tutorials
- Sample Images: Test images with various processed versions (rotated, filtered, etc.)
- Video Examples: Sample videos for testing processing algorithms
- Generated Results: Pre-processed example outputs for reference
- Python 3.8 or higher
- Virtual environment (recommended)
- Jupyter Notebook or JupyterLab (for interactive tutorials)
The project uses the following main libraries:
- OpenCV (4.12.0.88): Computer vision and image processing
- NumPy (2.2.6): Numerical computing and array operations
- Matplotlib (3.10.5): Plotting and visualization
- Pillow (11.3.0): Additional image processing capabilities
See requirements.txt for the complete list of dependencies with specific versions.
-
Clone the repository:
git clone https://github.com/your-username/opencv-learning.git cd opencv-learning -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Mac/Linux # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Install Jupyter (if not included in requirements):
pip install jupyter
-
Add your images to the
data/imgs/directory -
Run individual image processing functions:
from src.image_processing_funcs import * # Display image information show_image_info('data/imgs/woman.jpg') # Convert to grayscale gray_img = grayscale_img('data/imgs/woman.jpg') # Apply corner detection harris_corner_detection('data/imgs/woman.jpg', is_save=True) # Add noise and sharpen add_salt_and_pepper_noise('data/imgs/woman.jpg', is_save=True) sharpen_image('data/imgs/woman.jpg', is_save=True)
-
Run the main processing script:
python src/image_processing_funcs.py
-
Add video files to the
data/videos/directory -
Process videos:
from src.video_processing_funcs import * # Show video information show_video_info('data/videos/your_video.mp4') # Process live camera feed live_video_processing(cam_option=1) # Extract background/foreground background_foreground_extraction('data/videos/your_video.mp4', threshold=50)
-
Run video processing script:
python src/video_processing_funcs.py
-
Start Jupyter:
jupyter notebook
-
Open the learning notebooks:
src/computer-vision/deep-learning/introduction.ipynb- Deep learning fundamentalssrc/computer-vision/deep-learning/CNN/CNN.ipynb- Convolutional Neural Networkssrc/computer-vision/deep-learning/CNN/main.ipynb- CNN examples
-
Explore advanced concepts:
- Check
src/computer-vision/introduction/advanced_python_concepts.pyfor Python CV techniques - Review
src/computer-vision/deep-learning/CNN/30-38+CNN.pdffor theoretical background
- Check
# Image merging
merge_images(
img1_path='data/imgs/woman.jpg',
img2_path='data/imgs/grayscaled_woman.jpg',
direction='horizontal',
is_save=True
)
# Image rotation with different axes
rotate_img('data/imgs/woman.jpg', axis='X', angle=45, is_save=True)
# Bilateral filtering for noise reduction
bilateral_filter('data/imgs/woman.jpg')This project includes comprehensive educational materials for learning deep learning and computer vision:
-
Start with Python Fundamentals:
src/computer-vision/introduction/advanced_python_concepts.py- Essential Python concepts for computer vision work
-
Deep Learning Introduction:
src/computer-vision/deep-learning/introduction.ipynb- Fundamentals of deep learning for computer vision
-
Convolutional Neural Networks:
src/computer-vision/deep-learning/CNN/CNN.ipynb- Comprehensive CNN tutorialsrc/computer-vision/deep-learning/CNN/main.ipynb- Practical CNN examplessrc/computer-vision/deep-learning/CNN/30-38+CNN.pdf- Theoretical reference material
-
Experimental Playground:
src/computer-vision/pytorch-playground/- PyTorch experiments and advanced implementations
- Understand core computer vision concepts with OpenCV
- Learn image processing techniques and their applications
- Master CNN architecture and implementation
- Apply deep learning to computer vision problems
- Gain hands-on experience with real-world examples
- Begin with basic image processing functions in
src/image_processing_funcs.py - Experiment with video processing in
src/video_processing_funcs.py - Work through the Jupyter notebooks in order
- Try the example functions with your own images
- Explore the deep learning materials for advanced topics
- Turkcell Geleceği Yazanlar Opencv Course
- OpenCV Documentation
- Tutorials and resources from the OpenCV community.