-
Notifications
You must be signed in to change notification settings - Fork 4
Fix/workflows and imaging #74
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
base: main
Are you sure you want to change the base?
Changes from all commits
f5d1baf
a2c90fd
0210856
4040dad
d81a091
a86bb59
c8563bd
00c01b6
f43a310
6d572db
a788d04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,3 +30,4 @@ yapf==0.40.1 | |
| zipp==3.17.0 | ||
| ultralytics==8.3.128 | ||
| websockets==15.0.1 | ||
| depthai==2.32.0.0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,20 @@ | ||
| from src.modules.imaging.bucket_detector import BucketDetector | ||
| from src.modules.imaging.camera import DebugCameraFromDir | ||
| from src.modules.imaging.location import DebugLocationProvider | ||
| # from src.modules.imaging.analysis import ImageAnalysisDelegate | ||
| from src.modules.imaging.debug_analysis import DebugImageAnalysisDelegate | ||
| if __name__ == "__main__": | ||
| from src.modules.imaging.bucket_detector import BucketDetector | ||
| from src.modules.imaging.camera import DebugCameraFromDir | ||
| from src.modules.imaging.location import DebugLocationProvider | ||
| from src.modules.imaging.debug_analysis import DebugImageAnalysisDelegate | ||
|
|
||
| cam = DebugCameraFromDir("images") | ||
| det = BucketDetector("samples/models/n640.pt") | ||
| location = DebugLocationProvider() | ||
| analysis = DebugImageAnalysisDelegate(det, cam, location) | ||
| # analysis = ImageAnalysisDelegate(det, cam, location) | ||
|
|
||
| def test(a1, a2): | ||
| if a1 is not None and a2 is not None: | ||
| print(a1) | ||
| print(a2) | ||
|
|
||
| cam = DebugCameraFromDir("images") | ||
| det = BucketDetector("samples/models/n640.pt") | ||
| location = DebugLocationProvider() | ||
| analysis = DebugImageAnalysisDelegate(det, cam, location) | ||
| # analysis = ImageAnalysisDelegate(det, cam, location) | ||
|
|
||
| def test(a1, a2): | ||
| if a1 != None and a2 != None: | ||
| print(a1) | ||
| print(a2) | ||
|
|
||
| analysis.subscribe(test) | ||
|
|
||
| analysis.start() | ||
| analysis.subscribe(test) | ||
|
|
||
| analysis.start() |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why make any changes here? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,42 @@ | ||
| from src.modules.imaging.bucket_detector import BucketDetector | ||
| from src.modules.imaging.camera import DebugCameraFromDir, RPiCamera, DebugCamera | ||
| from src.modules.imaging.location import DebugLocationProvider | ||
| from src.modules.imaging.analysis import ImageAnalysisDelegate | ||
|
|
||
| from ultralytics import YOLO | ||
| import os | ||
|
|
||
| import cv2 | ||
| from PIL import Image | ||
| import time | ||
|
|
||
| cam = RPiCamera(0) | ||
| model_path = 'samples/models' | ||
| models = os.listdir(model_path) | ||
| models = ["best.pt"] | ||
| for file in models: | ||
| model = YOLO(os.path.join(model_path, file)) | ||
| i = len(os.listdir("photos")) | ||
| while True: | ||
| image = cam.capture() | ||
| image.save(f"photos/{i}.png") | ||
| results = model(image) | ||
| if __name__ == "__main__": | ||
| from src.modules.imaging.camera import RPiCamera | ||
| from ultralytics import YOLO | ||
|
|
||
| result = results[0] # because one image | ||
| a = result.plot() | ||
| # b = Image.fromarray(a) | ||
| # b.save(f"results/{i}.png") | ||
| # | ||
| cv2.imshow(f'Result for model: {file}', a) | ||
| cv2.waitKey(0) | ||
| cv2.destroyAllWindows() | ||
| time.sleep(0.5) | ||
| i += 1 | ||
| # boxes = result.boxes | ||
| cam = RPiCamera(0) | ||
| model_path = "samples/models" | ||
| models = os.listdir(model_path) | ||
| models = ["best.pt"] | ||
| for file in models: | ||
| model = YOLO(os.path.join(model_path, file)) | ||
| i = len(os.listdir("photos")) | ||
| while True: | ||
| image = cam.capture() | ||
| image.save(f"photos/{i}.png") | ||
| results = model(image) | ||
|
|
||
| # if boxes is not None and len(boxes) > 0: | ||
| # best_box = boxes[boxes.conf.argmax()] | ||
| # (x1, y1, x2, y2) = best_box.xyxy[0].tolist() # box [x1, y1, x2, y2] | ||
| # conf = best_box.conf.item() # confidence threshold | ||
| # if conf < 0.5: | ||
| # print("not confident") | ||
| # else: | ||
| # print("confident") | ||
| # else: | ||
| # print("no bounding box") | ||
| result = results[0] # because one image | ||
| a = result.plot() | ||
| # b = Image.fromarray(a) | ||
| # b.save(f"results/{i}.png") | ||
| # | ||
| cv2.imshow(f"Result for model: {file}", a) | ||
| cv2.waitKey(0) | ||
| cv2.destroyAllWindows() | ||
| time.sleep(0.5) | ||
| i += 1 | ||
| # boxes = result.boxes | ||
|
|
||
| # if boxes is not None and len(boxes) > 0: | ||
| # best_box = boxes[boxes.conf.argmax()] | ||
| # (x1, y1, x2, y2) = best_box.xyxy[0].tolist() # box [x1, y1, x2, y2] | ||
| # conf = best_box.conf.item() # confidence threshold | ||
| # if conf < 0.5: | ||
| # print("not confident") | ||
| # else: | ||
| # print("confident") | ||
| # else: | ||
| # print("no bounding box") |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why any changes here? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,38 @@ | ||
| import json | ||
| from src.modules.autopilot.lander import Lander | ||
| from src.modules.georeference import inference_georeference | ||
|
|
||
| with open('./samples/geofence.json', 'r') as f: | ||
| geofence = json.load(f)['features'][0]['geometry']['coordinates'][0] | ||
|
|
||
|
|
||
| origin = [-113.54815575690603, 53.495546666117804] | ||
|
|
||
| geofence = inference_georeference.Geofence_to_XY(origin, geofence) | ||
| print(geofence) | ||
|
|
||
| lander = Lander(0, 0, geofence) | ||
| ''' | ||
| point1 = [53.4958, -113.5477] | ||
| point2 = [53.4956, -113.5481] | ||
| point3 = [53.4956, -113.5475] | ||
| point4 = [53.4955, -113.5488] | ||
| point5 = [53.4955, -113.5488] | ||
| ''' | ||
| point1 = [0, 0] | ||
| point2 = [5, 5] | ||
| point3 = [10, 10] | ||
| point4 = [-5, -5] | ||
| point5 = [-10, 10] | ||
| point6 = [30.4, | ||
| 30.4] | ||
| point7 = [-113.54827877970348, | ||
| 53.49573842746909] | ||
|
|
||
|
|
||
| print(lander.geofence_check(point1)) | ||
| print(lander.geofence_check(point2)) | ||
| print(lander.geofence_check(point3)) | ||
| print(lander.geofence_check(point4)) | ||
| print(lander.geofence_check(point5)) | ||
| print(lander.geofence_check(point6)) | ||
| print(lander.geofence_check(point7)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| from src.modules.autopilot.lander import Lander | ||
| from src.modules.georeference import inference_georeference | ||
|
|
||
| if __name__ == "__main__": | ||
| with open("./samples/geofence.json", "r") as f: | ||
| geofence = json.load(f)["features"][0]["geometry"]["coordinates"][0] | ||
|
|
||
| origin = [-113.54815575690603, 53.495546666117804] | ||
|
|
||
| geofence = inference_georeference.Geofence_to_XY(origin, geofence) | ||
| print(geofence) | ||
|
|
||
| lander = Lander(0, 0, geofence) | ||
| """ | ||
| point1 = [53.4958, -113.5477] | ||
| point2 = [53.4956, -113.5481] | ||
| point3 = [53.4956, -113.5475] | ||
| point4 = [53.4955, -113.5488] | ||
| point5 = [53.4955, -113.5488] | ||
| """ | ||
| point1 = [0, 0] | ||
| point2 = [5, 5] | ||
| point3 = [10, 10] | ||
| point4 = [-5, -5] | ||
| point5 = [-10, 10] | ||
| point6 = [30.4, 30.4] | ||
| point7 = [-113.54827877970348, 53.49573842746909] | ||
|
|
||
| print(lander.geofence_check(point1)) | ||
| print(lander.geofence_check(point2)) | ||
| print(lander.geofence_check(point3)) | ||
| print(lander.geofence_check(point4)) | ||
| print(lander.geofence_check(point5)) | ||
| print(lander.geofence_check(point6)) | ||
| print(lander.geofence_check(point7)) |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why any changes here? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,16 @@ | ||
| from src.modules.imaging.detector import IrDetector | ||
| from src.modules.imaging.analysis import ImageAnalysisDelegate | ||
| from src.modules.imaging.camera import RPiCamera | ||
| from src.modules.imaging.location import DebugLocationProvider | ||
|
|
||
|
|
||
| camera = RPiCamera() | ||
| detector = IrDetector() | ||
| location = DebugLocationProvider() | ||
|
|
||
|
|
||
| def test(img, _): | ||
| print("Image taken") | ||
|
|
||
|
|
||
|
|
||
| analysis = ImageAnalysisDelegate(detector, camera, location) | ||
| analysis.subscribe(test) | ||
|
|
||
| analysis.start() | ||
| if __name__ == "__main__": | ||
| from src.modules.imaging.detector import IrDetector | ||
| from src.modules.imaging.analysis import ImageAnalysisDelegate | ||
| from src.modules.imaging.camera import RPiCamera | ||
| from src.modules.imaging.location import DebugLocationProvider | ||
| camera = RPiCamera() | ||
| detector = IrDetector() | ||
| location = DebugLocationProvider() | ||
|
|
||
| def test(img, _): | ||
| print("Image taken") | ||
|
|
||
| analysis = ImageAnalysisDelegate(detector, camera, location) | ||
| analysis.subscribe(test) | ||
|
|
||
| analysis.start() |
|
Manan-learner marked this conversation as resolved.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why make any changes here?