diff options
| author | Rishi-k-s <rishikrishna.sr@gmail.com> | 2024-04-21 14:15:09 +0530 |
|---|---|---|
| committer | Rishi-k-s <rishikrishna.sr@gmail.com> | 2024-04-21 14:15:09 +0530 |
| commit | d9a5b5b317ee144105ac58f711581194b427d15c (patch) | |
| tree | b4f8e33622918808a6fb0e6a531c202b8d20f2d9 | |
| parent | 7bfe5069163fc0475f9f9a51ddbc16143f064d3d (diff) | |
fixed the py to arduino thing
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | output.json | 1 | ||||
| -rw-r--r-- | test.py | 46 | ||||
| -rw-r--r-- | test_of_esp.ino/test_of_esp.ino.ino | 13 |
4 files changed, 55 insertions, 7 deletions
@@ -3,7 +3,7 @@ An AI based conveyor system that utilizes image recognition capabilities to segr ### Team Members [1.Sarath Madhav](https://github.com/Pseudozoid) -[2.Rishi Krishna ](https://github.com/Rishi-ks) +[2.Rishi Krishna ](https://github.com/Rishi-k-s) [3.Roshan Cyriac](https://github.com/RoshanCy85) [4.Vishnu Rajagopal](https://github.com/Vishnudrm) diff --git a/output.json b/output.json new file mode 100644 index 0000000..fb86731 --- /dev/null +++ b/output.json @@ -0,0 +1 @@ +{"predictions": [{"x": 221.0, "y": 466.0, "width": 284.0, "height": 196.0, "confidence": 0.9601893424987793, "class": "1", "class_id": 1, "detection_id": "8eb9dbc2-edba-41dd-b688-8c6fdb3c30a5", "image_path": "./syringe.jpg", "prediction_type": "ObjectDetectionModel"}, {"x": 180.0, "y": 306.0, "width": 304.0, "height": 288.0, "confidence": 0.9401327967643738, "class": "1", "class_id": 1, "detection_id": "39c0f674-3d35-4f99-8b2d-f6aa6f26a865", "image_path": "./syringe.jpg", "prediction_type": "ObjectDetectionModel"}, {"x": 351.5, "y": 608.5, "width": 81.0, "height": 41.0, "confidence": 0.9194074869155884, "class": "0", "class_id": 0, "detection_id": "1f440d8b-c133-4c3a-b4ea-2fa43fa94a29", "image_path": "./syringe.jpg", "prediction_type": "ObjectDetectionModel"}, {"x": 384.0, "y": 575.5, "width": 66.0, "height": 43.0, "confidence": 0.9019243717193604, "class": "0", "class_id": 0, "detection_id": "3081c5bf-49ab-42ca-8827-b0ab3ed604b1", "image_path": "./syringe.jpg", "prediction_type": "ObjectDetectionModel"}], "image": {"width": "1024", "height": "683"}}
\ No newline at end of file @@ -1,25 +1,61 @@ import serial.tools.list_ports
+from roboflow import Roboflow
+import json
ports = serial.tools.list_ports.comports()
serialInst = serial.Serial()
+rf = Roboflow(api_key="otKMUXAELXaU2XZsT77M")
+project = rf.workspace().project("biomedical-wastes")
+model = project.version(3).model
+
+json_response = model.predict("./syringe.jpg", confidence=40, overlap=30).json()
+
portsList = []
# portvar = ""
for onePort in ports:
portsList.append(str(onePort))
print (str(onePort))
-val = input("Select Port: COM")
+val = "9"
for x in range(0,len(portsList)):
if portsList[x].startswith("COM" + str(val)):
portvar = "COM" + str(val)
print (portvar)
-serialInst.baudrate = 9600
+serialInst.baudrate = 115200
serialInst.port = portvar
serialInst.open()
-while True:
- cmd = input("ON/OFF")
- serialInst.write(cmd.encode('utf-8'))
\ No newline at end of file +isTest= True;
+while isTest:
+ threshold = 0.8
+ for prediction in json_response["predictions"]:
+ if prediction["confidence"] > threshold:
+ # Do something specific
+ print("Syringe detected!")
+ cmd = "INJD"
+ serialInst.write(cmd.encode('utf-8'))
+ isTest=False
+ break;
+
+ # save the JSON response to a file
+ with open('output.json', 'w') as f:
+ json.dump(json_response, f)
+
+
+
+
+
+
+
+
+
+
+
+# infer on a local image
+
+
+
+
diff --git a/test_of_esp.ino/test_of_esp.ino.ino b/test_of_esp.ino/test_of_esp.ino.ino index be295e4..f72446b 100644 --- a/test_of_esp.ino/test_of_esp.ino.ino +++ b/test_of_esp.ino/test_of_esp.ino.ino @@ -1,6 +1,14 @@ +// #include <DHT.h> +// #define DHTPIN 7 +// #define DHTTYPE DHT11 +int gasInput = A0; + +// DHT dht (DHTPIN, DHTTYPE); + void setup() { Serial.begin(9600); - pinMode(BUILTIN_LED, OUTPUT); + pinMode(gasInput, INPUT); + // dht.begin(); } @@ -16,6 +24,9 @@ void loop() { digitalWrite(BUILTIN_LED,HIGH); } } + Serial.println( analogRead(gasInput) ); + delay(500); + } |
