Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moicci/cv2operator
simple library to input various shapes like polygon rectangle and so on.
https://github.com/moicci/cv2operator
image-processing opencv opencv-python python
Last synced: 11 days ago
JSON representation
simple library to input various shapes like polygon rectangle and so on.
- Host: GitHub
- URL: https://github.com/moicci/cv2operator
- Owner: moicci
- License: mit
- Created: 2020-01-29T09:11:16.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-01T02:51:06.000Z (almost 5 years ago)
- Last Synced: 2024-10-11T22:40:25.842Z (about 1 month ago)
- Topics: image-processing, opencv, opencv-python, python
- Language: Python
- Size: 1.53 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-jp.md
- License: LICENSE
Awesome Lists containing this project
README
# cv2operator
cv2 (OpenCV) のウィンドウで線、ループなどを入力するためのライブラリです。
![](docs/polygon-op.png)
## 機能
- **LineOperator**: ドラッグで線を入力する
- **PolylineOperator**: 点をクリックして行き折れ線を入力する
- **PolygonOperator**: 点をクリックして行きポリゴンを入力する
- **RectOperator**: ドラッグで矩形を入力する
- **BrushOperator**: ドラッグでマスク領域を塗りつぶす
- **KeyOperator**: ウィンドウでのキー管理## 使い方
LineOperator の使い方はこんな感じです。
```
import cv2
from cv2operator import KeyOperator, OperartorWindow, LineOperatordef line_cb(p1, p2):
print(f"line: p1={p1}, p2={p2}")image = cv2.imread("goru.jpg")
window = OperartorWindow("example", image)line_op = LineOperator(window, callback=line_cb)
key_op = KeyOperator()
print(key_op.help())
key_op.main_loop()
```## その他の入力
その他については [examples](https://github.com/moicci/cv2operator/tree/master/examples) の [demo.py](https://github.com/moicci/cv2operator/tree/master/examples/demo.py) を参照してください。
こんな入力が可能です。
### RectOperator
![image](https://raw.githubusercontent.com/moicci/cv2operator/master/docs/rect-op.png)
### LineOperator
![image](https://raw.githubusercontent.com/moicci/cv2operator/master/docs/line-op.png)
### PolylineOperator
![image](https://raw.githubusercontent.com/moicci/cv2operator/master/docs/polyline-op.png)
### PolygonOperator
![image](https://raw.githubusercontent.com/moicci/cv2operator/master/docs/polygon-op.png)
### BrushOperator
![image](https://raw.githubusercontent.com/moicci/cv2operator/master/docs/brush-op.png)