Skip to content

Instantly share code, notes, and snippets.

View jjahanip's full-sized avatar
🏠
Working from home

Jahandar Jahanipour jjahanip

🏠
Working from home
View GitHub Profile
import tkinter as tk
# Function to handle button clicks
def button_click(event):
current = entry.get()
text = event.widget.cget("text")
if text == "=":
try:
result = eval(current)
@jjahanip
jjahanip / sam_annotator.py
Last active May 19, 2023 18:59
Annotator for points and boxes on the image for SAM using cv2 (keyboard shortcuts: p = point selection mode | b = box selection mode | q = quit)
def annotate_image(image):
# Create a copy of the image to draw annotations on
annotated_image = image.copy()
# Create lists to store the annotated points and boxes
points = []
boxes = []
point_labels = []
unscaled_points = [] # To store unscaled points
unscaled_boxes = [] # To store unscaled boxes