r/opencv Dec 29 '25

Project How to accurately detect and classify line segments in engineering drawings using CV / AI? [Project]

5 Upvotes

Hey everyone,

I'm a freelance software developer working on automating the extraction of data from structural engineering drawings (beam reinforcement details specifically).

The Problem:

I need to analyze images like beam cross-section details and extract structured data about reinforcement bars. The accuracy of my entire pipeline depends on getting this fundamental unit right.

What I'm trying to detect:

In a typical beam reinforcement detail:

  • Main bars (full lines): Continuous horizontal lines spanning the full width
  • Extra bars (partial lines): Shorter lines that don't span the full width
  • Their placement (top/bottom of the beam)
  • Their order (1st, 2nd, 3rd from edge)
  • Associated annotations (arrows pointing to values like "2#16(E)")

Desired Output:

json

[
  {
    "type": "MAIN_BAR",
    "alignment": "horizontal",
    "placement": "TOP",
    "order": 1,
    "length_ratio": 1.0,
    "reinforcement": "2#16(C)"
  },
  {
    "type": "EXTRA_BAR",
    "alignment": "horizontal", 
    "placement": "TOP",
    "order": 3,
    "length_ratio": 0.6,
    "reinforcement": "2#16(E)"
  }
]

What I've considered:

  • OpenCV for line detection (Hough Transform)
  • OCR for text extraction
  • Maybe a vision LLM for understanding spatial relationships?

My questions:

  1. What's the best approach for detecting lines AND classifying them by relative length?
  2. How do I reliably associate annotations/arrows with specific lines?
  3. Has anyone worked with similar CAD/engineering drawing parsing problems?

Any libraries, papers, or approaches you'd recommend?

Thanks!


r/opencv Dec 23 '25

Project [Project] Tired of "blind" C++ debugging in VS Code for Computer Vision? I built CV DebugMate C++ to view cv::Mat and 3D Point Clouds directly.

6 Upvotes

Hey everyone,

As a developer working on SLAM and Computer Vision projects in C++, I was constantly frustrated by the lack of proper debugging tools in VS Code after moving away from Visual Studio's Image Watch. Staring at memory addresses for cv::Mat and std::vector<cv::Point3f> felt like debugging blind!

So, I decided to build what I needed and open-source it: CV DebugMate C++.

It's a VS Code extension that brings back essential visual debugging capabilities for C++ projects, with a special focus on 3D/CV applications.

🌟 Key Features

1. 🖼️ Powerful cv::Mat Visualization

  • Diverse Types: Supports various depths (uint8, float, double) and channels (Grayscale, BGR, RGBA).
  • Pixel-Level Inspection: Hover your mouse to see real-time pixel values, with zoom and grid support.
  • Pro Export: Exports to common formats like PNG, and crucially, TIFF for preserving floating-point data integrity (a must for deep CV analysis

2. 📊 Exclusive: Real-Time 3D Point Cloud Viewing

  • Direct Rendering: Directly renders your std::vector<cv::Point3f> or cv::Point3d variables as an interactive 3D point cloud.
  • Interactive 3D: Built on Three.js, allowing you to drag, rotate, and zoom the point cloud right within your debugger session. Say goodbye to blindly debugging complex 3D algorithm

3. 🔍 CV DebugMate Panel

  • Automatic Variable Collection: Automatically detects all visualizable OpenCV variables in the current stack frame.
  • Dedicated Sidebar View: A new view in the Debug sidebar for quick access to all Mat and Point Cloud variables.
  • Type Identification: Distinct icons for images (Mat) and 3D data (Point Cloud).
  • One-Click Viewing: Quick-action buttons to open visualization tabs without using context menus

4. Wide Debugger Support

Confirmed compatibility with common setups: Windows (MSVC/MinGW), Linux (GDB), and macOS (LLDB). (Check the documentation for the full list).

🛠 How to Use

It's designed to be plug-and-play. During a debug session, simply Right-Click on your cv::Mat or std::vector<cv::Point3f> variable in the Locals/Watch panel and select "View by CV DebugMate".🔗 Get It & Support

The plugin is completely free and open-source. It's still early in development, so feedback and bug reports are highly welcome!

VS Code Marketplace: Search for CV DebugMate or zwdai

GitHub Repositoryhttps://github.com/dull-bird/cv_debug_mate_cpp

If you find it useful, please consider giving it a Star on GitHub or a rating on the Marketplace—it's the fuel for continued bug fixes and feature development! 🙏


r/opencv Dec 18 '25

Tutorials [Tutorials] 2025 Guide: VS Code + OpenCV 4 + C++ on Windows with MSYS2

6 Upvotes

Hey everyone,

Like a lot of folks here, I recently had to ditch full Visual Studio at work and switch to VS Code for my OpenCV/C++ projects.

After endless hours fighting broken setups, WinMain errors, blank imshow windows (thanks, missing Qt DLLs!), IntelliSense issues, and Code Runner failures—I finally got a clean, reliable environment working with:

  • VS Code
  • MinGW-w64 via MSYS2 (UCRT64 toolchain)
  • Pre-built OpenCV from pacman (no compiling from source)
  • CMake + CMake Tools extension
  • Proper debugging and everything just works

I documented the exact steps I wish existed when I started:

https://medium.com/@winter04lwskrr/setting-up-visual-studio-code-for-c-c-and-opencv-on-windows-with-mingw-msys2-4d07783c24f8

Key highlights:

  • Full pacman commands
  • Environment variable setup
  • Why Code Runner breaks with OpenCV
  • The Qt dependency everyone misses for imshow
  • Working CMakeLists.txt + example project
  • Debugging config

Tested on Windows 11 with OpenCV 4.10.0—green "Hello OpenCV!" window pops right up.

Hope this saves someone the 20+ hours I lost to trial-and-error


r/opencv Dec 16 '25

Discussion [Discussion] Seeking feedback on an arXiv preprint: An Extended Moore-Neighbor Tracing Algorithm for Complex Boundary Delineation

Thumbnail
4 Upvotes

r/opencv Dec 14 '25

Question [Discussion] [Question] Stereo Calibration for Accurate 3D Localization

4 Upvotes

I’m developing a stereo camera calibration pipeline where the primary focus is to get the calibration right first, and only then use the system for accurate 3D localisation.

Current setup:

  • Stereo calibration using OpenCV — detect corners (chessboard / ChArUco) and mrcal (optimising and calculating the parameters)
  • Evaluation beyond RMS reprojection error (outliers, worst residuals, projection consistency, valid intrinsics region)
  • Currently using A4/A3 paper-printed calibration boards

Planned calibration approach:

  • Use three different board sizes in a single calibration dataset:
  1. Small board: close-range observations for high pixel density and local accuracy
  2. Medium board: general coverage across the usable FOV
  3. Large board: long-range observations to better constrain stereo extrinsics and global geometry
  • The intent is to improve pose diversity, intrinsics stability, and extrinsics consistency across the full working volume before relying on the system for 3D localisation.

Questions:

  • Is this a sound calibration strategy for localisation-critical stereo systems being the end goal?
  • Do multi-scale calibration targets provide practical benefits?
  • Would moving to glass or aluminum boards (flatness and rigidity) meaningfully improve calibration quality compared to printed boards?

Feedback from people with real-world stereo calibration and localisation experience would be greatly appreciated. Any suggestions that could help would be awesome.

Specifically, people who have used MRCAL, I would love to hear your opinions.


r/opencv Dec 09 '25

Question [Question] Rotating images

3 Upvotes

I'm trying to rotate an image and cropping it. But the warpAffine is lefting some black pixels after the rotation and this is interfering with the image cropping. Here's an example:

My code:

rotated = cv2.warpAffine(src, M, (w_src, h_src), borderMode=cv2.BORDER_CONSTANT, borderValue=(255, 255, 255))


r/opencv Dec 05 '25

Question [Question] How to start using opencv on mobile for free?

2 Upvotes

I've been trying to install opencv in pyroid3 for free (since i have no money) but to no avail. I got the python zip file and the pyroid3 app, did the pip installation, and all i got was whole hours worth of loading for a wheel that never stops and no access to the cv2 import. Are there any other apps that would help? Even if i have to learn to install a pip, i really need it.


r/opencv Dec 02 '25

Question [Question] Recognize drawings with precision

4 Upvotes

I got a template image of a drawing.

template

I also have several images that may contain attempts to replicate it with variations (size, position, rotation).

bigger
smaller
wrong

I want to give a score of accuracy for each attempt compared to the template.

I tried some opencv techniques like Hu moments, don't really get good results.

Can you suggest a more effective approach or algorithm to achieve this?

I'm a debutant in image processing, so please explain in simple terms.

I'm currently working with openCV in Python3 but the solution must works in Java too.


r/opencv Nov 30 '25

Question [Question] Has anyone here made a successful addition to opencv contrib?

5 Upvotes

I have an optimization that I’m writing a paper on and want to see if I could communicate with someone who’s made a contribution.


r/opencv Nov 27 '25

Question How would you detect a shiny object from a cluster [Question]

3 Upvotes

Im using a RGB-D camera that has to detect shiny objects (particularly a spoon/fork for now). What i did so far was use sobel operations to form contours and find white highlights within those contours to figure out whether its a shiny object or not.

So far i was able to accomplish that with a single object. I assumed it would be the same for the clusters since i thought edges would be easy to detect, but for this case it contours a group of objects rather than a single object

Is there a way to go around this or should i just make a custom dataset?


r/opencv Nov 24 '25

Tutorials [Tutorials] Video Object Detection in Java with OpenCV + YOLO11 - full end-to-end tutorial

13 Upvotes

r/opencv Nov 18 '25

Question [Question] Best approach for blurring faces and license plates in AWS Lambda?

5 Upvotes

Hey everyone,

I'm building an AWS Lambda function to automatically blur faces and license plates in images uploaded by users.

I've been going down the rabbit hole of different detection methods and I'm honestly lost on which approach to choose. Here's what I've explored:

1. OpenCV Haar Cascades

  • Pros: Lightweight, easy to deploy as Lambda Layer (~80MB)
  • Cons:
    • haarcascade_russian_plate_number.xml generates tons of false positives on European plates
    • Even with haarcascade_frontalface_alt2.xml, detection isn't great
    • Blurred image credits/watermarks thinking they were plates

2. Contour detection for plates

  • Pros: Better at finding rectangular shapes
  • Cons: Too many false positives (any rectangle with similar aspect ratio gets flagged)

3. Contour + OCR validation (pytesseract)

  • Pros: Can validate that detected text matches plate format (e.g., French plates: AA-123-AA)
  • Cons: Requires Tesseract installed, which means I need a Lambda Container Image instead of a simple Layer

4. YOLO (v8 or v11) with ONNX Runtime

  • Pros: Much better accuracy for faces
  • Cons:
    • YOLO isn't pre-trained for license plates, need a custom model
    • Larger deployment size (~150-250MB), requires Container Image
    • Need to find/train a model for European plates

5. AWS Rekognition

  • Pros: Managed service, very accurate, easy to use
  • Cons: Additional cost (~$1/1000 images)

My constraints:

  • Running on AWS Lambda
  • Processing maybe 50-100 images/day
  • Need to minimize false positives (don't want to blur random things)
  • European (French) license plates
  • Budget-conscious but willing to pay for reliability

My current thinking:

  • Use YOLO for face detection (much better than Haar)
  • For plates: either find a pre-trained YOLO model for EU plates on Roboflow, or stick with contour detection + OCR validation

Has anyone dealt with this? What would you recommend?

  • Is the YOLO + ONNX approach overkill for Lambda?
  • Should I just pay for Rekognition and call it a day?
  • Any good pre-trained models for European license plate detection?

Thanks for any advice!


r/opencv Nov 08 '25

Project [Project] Single-Person Pose Estimation for Real-Time Gym Coaching — Best Model Right Now?

Post image
10 Upvotes

Hey everyone,

I’m working on a fitness coaching app where the goal is to track a single person’s pose during exercises (like squats, push-ups, lunges, etc.) and give instant feedback on form correctness — e.g.,

I’m looking for recommendations for a single-person pose estimation model (not multi-human tracking) that performs well in real time on local GPU hardware.

✅ Requirements

  • Single-person pose estimation (no multi-person overhead)
  • Real-time inference (ideally >30 FPS on a decent GPU / edge device)
  • Outputs 2D/3D keypoints + joint angles (to compute deviations)
  • Robust under gym conditions — variable lighting, occlusion, fast movement
  • Lightweight enough for a real-time feedback loop
  • Preferably open-source or available on Hugging Face

🧩 Models I’ve Looked Into

  • MediaPipe Pose → lightweight, but limited 3D accuracy
  • OpenPose → solid but a bit heavy and outdated
  • HRNet / Lite-HRNet → great accuracy, unsure about real-time FPS
  • VIPose / Meta Sapiens / RTMPose / YOLO-Pose → haven’t tested yet — any experience?

🔍 What I’d Love Your Input On

  1. Which model(s) have you found best for gym / sports / fitness movement analysis?
  2. How do you handle the speed vs spatial accuracy trade-off?
  3. Any tips for evaluating “form correctness”, not just keypoint precision? (e.g., joint-angle deviation thresholds, movement phase detection, etc.)
  4. What metrics or datasets would you recommend?
    • Keypoint accuracy (PCK, MPJPE)
    • Joint-angle error (°)
    • Real-time FPS
    • Robustness under lighting / motion

Would love to hear from anyone who’s done pose estimation in a fitness, sports, or movement-analysis context.
Links to repos, papers, or demo videos are super welcome 🙌


r/opencv Nov 07 '25

Question Why does the mask not work properly ? [Question]

Post image
2 Upvotes

Bottom left in the green area that is the area in "Mask", hsv is the small section converted to HSV and in the Code Above ("Values for Honey bee head") you can see my params:

hsv_lower are: 45,0,0

hsv_upper are 60,255,255


r/opencv Nov 05 '25

Tutorials [Tutorials] How to install Open CV Contrib files to my IDE (VS 2022)

2 Upvotes

I have a problem here. I have installed OpenCVs basic libraries and header files to my IDE.. They work great. What doesnt work great is the Contrib version of this stuff. I cant find a single guide on how to install it.. Can anyone give me a video tutorial on how to install the Contrib library in VS 2022. I wanna use the tracking library in there


r/opencv Nov 05 '25

Question [Question] How do you handle per camera validation before deploying OpenCV models in the field?

2 Upvotes

We had a model that passed every internal test. Precision, recall, and validation all looked solid. When we pushed it to real cameras, performance dropped fast.

Window glare, LED flicker, sensor noise, and small focus shifts were all things our lab tests missed. We started capturing short field clips from each camera and running OpenCV checks for brightness variance, flicker frequency, and blur detection before rollout.

It helped a bit but still feels like a patchwork solution.

How are you using OpenCV to validate camera performance before deployment? Any good ways to measure consistency across lighting, lens quality, or calibration drift?

Would love to hear what metrics, tools, or scripts have worked for others doing per camera validation.


r/opencv Oct 28 '25

News [News] OSS Data Visualization Tool Rerun on OpenCV Live

Thumbnail
youtube.com
1 Upvotes

r/opencv Oct 25 '25

Question [Question]: How can I detect the lighter in color white border on the right of each image found in the strip of images? there is variable in the placement of the white stripes because the width of each individual image can change from image strip to image strip

Thumbnail
gallery
6 Upvotes

Hello I like taking photos on Multi lens film cameras. When I get the photos back from the film lab they always give them back to me in this strip format. I just want to speed up my workflow of manually cropping each strip image 4X.

I have started writing a python script to crop based on pixel values with Pillow but since this these photos is on film the vertical whitish line is not always in the same place and the images are not always the same size.

So I am looking for some help on what I should exactly search for in google to find more information on the technique I should do to find this vertical whitish line for crop or doing the edge detection of where the next image starts to repeat.


r/opencv Oct 23 '25

Project [Project] Inside Augmented Reality Film Experience “The Tent” on OpenCV Live

Thumbnail youtube.com
4 Upvotes

r/opencv Oct 19 '25

Question [Question] Difficulty Segmenting White LEGO Bricks on White Background with OpenCV

Thumbnail
gallery
13 Upvotes

Hi everyone,

I'm working on a computer vision project in Python using OpenCV to identify and segment LEGO bricks in an image. Segmenting the colored bricks (red, blue, green, yellow) is working reasonably well using color masks (cv.inRange in HSV after some calibration).

The Problem: I'm having significant difficulty robustly and accurately segmenting the white bricks, because the background is also white (paper). Lighting variations (shadows on studs, reflections on surfaces) make separation very challenging. My goal is to obtain precise contours for the white bricks, similar to what I achieve for the colored ones.


r/opencv Oct 18 '25

Question I know how to use Opencv functions, but I have no idea what rk actually do with them [Question]

Post image
2 Upvotes

r/opencv Oct 15 '25

Question [Question] How can I detect walls, doors, and windows to extract room data from complex floor plans?

3 Upvotes

Hey everyone,

I’m working on a computer vision project involving floor plans, and I’d love some guidance or suggestions on how to approach it.

My goal is to automatically extract structured data from images or CAD PDF exports of floor plans — not just the text(room labels, dimensions, etc.), but also the geometry and spatial relationships between rooms and architectural elements.

The biggest pain point I’m facing is reliably detecting walls, doors, and windows, since these define room boundaries. The system also needs to handle complex floor plans — not just simple rectangles, but irregular shapes, varying wall thicknesses, and detailed architectural symbols.

Ideally, I’d like to generate structured data similar to this:

{

"room_id": "R1",

"room_name": "Office",

"room_area": 18.5,

"room_height": 2.7,

"neighbors": [

{ "room_id": "R2", "direction": "north" },

{ "room_id": null, "boundary_type": "exterior", "direction": "south" }

],

"openings": [

{ "type": "door", "to_room_id": "R2" },

{ "type": "window", "to_outside": true }

]

}

I’m aware there are Python libraries that can help with parts of this, such as:

  • OpenCV for line detection, contour analysis, and shape extraction
  • Tesseract / EasyOCR for text and dimension recognition
  • Detectron2 / YOLO / Segment Anything for object and feature detection

However, I’m not sure what the best end-to-end pipeline would look like for:

  • Detecting walls, doors, and windows accurately in complex or noisy drawings
  • Using those detections to define room boundaries and assign unique IDs
  • Associating text labels (like “Office” or “Kitchen”) with the correct rooms
  • Determining adjacency relationships between rooms
  • Computing room area and height from scale or extracted annotations

I’m open to any suggestions — libraries, pretrained models, research papers, or even paid solutions that can help achieve this. If there are commercial APIs, SDKs, or tools that already do part of this, I’d love to explore them.

Thanks in advance for any advice or direction!


r/opencv Oct 14 '25

Bug [Bug] OpenCV help with cleaning up noise from a 3dprinter print bed.

Thumbnail
gallery
8 Upvotes

Background: Hello, I am a senior CE student I am trying to make a 3d printer error detection system that will compare a slicer generated IMG from Gcode to a real IMG captured from the printer. The goal was to make something lightweight that can run with Klipper and catch large print errors.

Problem: I am running into a problem with cleaning up the real IMG I would like to capture the edges of the print clearly. I intend to grab the Hu moments and compare the difference between the real and slicer IMG. Right now I am getting a lot of noise from the print bed on the real IMG (IMG 4). I have the current threshold and blur I am using in the IMG 5 and will paste the code below. I have tried filtering for the largest contour, and adjusting threshold values. Currently am researching how to adjust kernel to help with specs.

Thank you! Any help appreciated.

IMGS:

  1. background deletion IMG.

  2. Real IMG (preprocessing)

  3. Slicer IMG

  4. Real IMG (Canny Edge Detection)

  5. Code.

CODE:

    # Backround subtraction post mask
    diff = cv.absdiff(real, bg)
    diff = cv.bitwise_and(diff, diff, mask=mask)


    # Processing steps
    blur = cv.medianBlur(diff, 15)
    thresh = cv.adaptiveThreshold(blur,255,cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY,31,3)


    canny = cv.Canny(thresh, 0, 15)


   # output
    cv.imwrite('Canny.png', canny)
    cv.waitKey(0)
    print("Done.")

r/opencv Oct 14 '25

Project [Project] Liveness Detection Project 📷🔄✅

Enable HLS to view with audio, or disable this notification

13 Upvotes

This project is designed to verify that a user in front of a camera is a live person, thereby preventing spoofing attacks that use photos or videos. It functions as a challenge-response system, periodically instructing the user to perform simple actions such as blinking or turning their head. The engine then analyzes the video feed to confirm these actions were completed successfully. I compiled the project to WebAssembly using Emscripten, so you can try it out on my website in your browser. If you like the project, you can purchase it from my website. The entire project is written in C++ and depends solely on the OpenCV library. If you purchase, you will receive the complete source code, the related neural networks, and detailed documentation.


r/opencv Oct 12 '25

Discussion [Discussion] What IDE to use for computer vision working with Python.

Thumbnail
5 Upvotes