Skip to content

This python script draws a border around any object in the foreground of a selected picture. The object in the foreground is detected using rembg library and uses openCV to edit the image as per the requirements.

Notifications You must be signed in to change notification settings

Jarosh-Antony/Auto-border-drawing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Auto-border-drawing

This python script draws a border around any object in the foreground of a selected rectangular region in the specified picture. The object in the foreground is detected using rembg library and uses openCV to edit the image as per the requirements.

Requirements

python: >3.7, <3.11 requirement for rembg
rembg
OpenCV-Python

Installation

Clone this repo.

git clone https://github.com/Jarosh-Antony/Auto-border-drawing

Create a virtual environment and activate it. You can read about the creation and activation of virtual environment here.

pip install opencv-python
pip install rembg

OR

pip install -r requirement.txt

Usage

The script can only run as a CLI.

  • The flag -i is a must to specify the path of input image.
  • The flag -o is optional. It specifies the output path and filename of the image while saving. Default saving path is same as input with filename appended with _output and uses same extension. While specifying the output filename, if the extension is not provided or OpenCV cannot save with specified extension, it uses the same extension of the input image.

Windows

python main.py -i input.jpg

Linux

python3 main.py -i input.jpg

Steps to follow:

  • Use mouse to select a region by "click and drag".
  • Press "ENTER" button to validate the region drawn by mouse.
  • Press "c" button to delete all borders and load original image.
  • Press "s" button to save the image with border. to the filename.
  • Press "q" button to close or quit the script.

About

This python script draws a border around any object in the foreground of a selected picture. The object in the foreground is detected using rembg library and uses openCV to edit the image as per the requirements.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages