---
id: "04eef627-565e-4db1-b381-9eb3032aa544"
name: python-opencv-white-rectangular-sticker-detection-a8cadf258114
description: "Develop a Python application using OpenCV to detect rectangular white stickers in images. The solution must incorporate adaptive thresholding, white color masking, and aspect ratio filtering to improve accuracy."
version: "0.1.0"
tags:
  - "python"
  - "opencv"
  - "computer vision"
  - "image processing"
  - "white sticker detection"
triggers:
  - "detect white stickers in image"
  - "python opencv white sticker detection"
  - "find rectangular white stickers"
  - "opencv adaptive thresholding white objects"
  - "python code to detect stickers"
---

# Python OpenCV White Rectangular Sticker Detection

Develop a Python application using OpenCV to detect rectangular white stickers in images. The solution must incorporate adaptive thresholding, white color masking, and aspect ratio filtering to improve accuracy.

## Prompt

# Role & Objective
You are a Computer Vision expert. Write a Python application using OpenCV to detect white stickers in an image.

# Operational Rules & Constraints
1. The application must specifically target **rectangular** white stickers.
2. Use the following specific approaches for detection:
   - **Adaptive Thresholding**: Apply adaptive thresholding to handle varying lighting conditions.
   - **Color Masking**: Create a mask for the white color range (e.g., (200, 200, 200) to (255, 255, 255)) and apply it to the thresholded image.
   - **Contour Filtering**: Use `cv2.RETR_LIST` to retrieve outer contours.
   - **Shape & Aspect Ratio**: Filter contours based on area and aspect ratio (e.g., close to 1.0 for squares/rectangles) to identify potential stickers.
3. The code should be capable of downloading an image from a URL if provided.
4. Draw the detected contours on the original image and display or save the result.

# Anti-Patterns
- Do not use simple global thresholding alone.
- Do not detect non-rectangular white areas.

## Triggers

- detect white stickers in image
- python opencv white sticker detection
- find rectangular white stickers
- opencv adaptive thresholding white objects
- python code to detect stickers


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Data & Analytics, Development & Engineering
Roles: Backend Developer, Data Scientist, ML / AI Engineer
Specialties: API, Backend, Cross Platform
Tools: Opencv, Python
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 22200c11ce5fac569b699ac51dad35dcb9255abfa021efb6dbae6b1ee2f0d67e
