Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crop by foreground and fix a bug with target classes csv_to_yolo #106

Open
wants to merge 6 commits into
base: ais
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated;
RugvedMavidipalli committed Jan 17, 2025
commit 1c53070a8f9b65ece6b487a10c33c5b7242a43c3
6 changes: 3 additions & 3 deletions lmi_utils/label_utils/crop_by_foreground.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

def cropped_bbox(bbox1, bbox2):
def crop_bbox(bbox1, bbox2):
crop_x1, crop_y1, crop_x2, crop_y2 = bbox1
target_x1, target_y1, target_x2, target_y2 = bbox2
adjusted_x1 = target_x1 - crop_x1
@@ -111,7 +111,7 @@ def main():
x1,y1 = shape.up_left
x2,y2 = shape.bottom_right
bbox = [x1,y1,x2,y2]
updated_bbox = cropped_bbox(foreground_shapes[fname]['foreground'], bbox)
updated_bbox = crop_bbox(foreground_shapes[fname]['foreground'], bbox)
annots[updated_fname].append(
Rect(
up_left=[updated_bbox[0], updated_bbox[1]],
@@ -143,7 +143,7 @@ def main():
x1,y1,x2,y2 = foreground_shapes[fname]['foreground']
cropped_image = image[y1:y2, x1:x2]

cv2.imwrite(os.path.join(updated_fname), cropped_image)
cv2.imwrite(os.path.join(args['path_out'], updated_fname), cropped_image)


# save the updated shapes