From a358a0bbc889693f706bba3891820e371395b647 Mon Sep 17 00:00:00 2001 From: Shahrul Kamil bin Hassan <shahrulkamil98@g.ucla.edu> Date: Wed, 6 Oct 2021 00:32:09 +0000 Subject: [PATCH] Replace Camera.cpp --- Code/Kamil's Feather Code/Camera.cpp | 58 ++++++++-------------------- 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/Code/Kamil's Feather Code/Camera.cpp b/Code/Kamil's Feather Code/Camera.cpp index 269337e..539896f 100644 --- a/Code/Kamil's Feather Code/Camera.cpp +++ b/Code/Kamil's Feather Code/Camera.cpp @@ -21,21 +21,6 @@ void Camera::exe_face_detection(){ Serial.println(F("]")); } } - -void Camera::exe_person_detection(){ - char buff[32 + 1] = {}; // null terminator - if (interface->call_no_args(F("person_detection"), buff, sizeof(buff) - 1)) { - Serial.println(buff); - } -} - -void Camera::exe_qrcode_detection(){ - char buff[128 + 1] = {}; // null terminator - if (interface->call_no_args(F("qrcode_detection"), buff, sizeof(buff) - 1)) { - Serial.print("qrdetected: "); - Serial.println(buff); - } -} bool Camera::exe_apriltag_detection(int ID,int *x_temp,int *y_temp,int *angle_temp){ struct { uint16_t cx, cy, rot; } result; @@ -50,20 +35,6 @@ bool Camera::exe_apriltag_detection(int ID,int *x_temp,int *y_temp,int *angle_te return true; } } - -void Camera::exe_datamatrix_detection(){ - char buff[128 + 1] = {}; // null terminator - if (interface->call_no_args(F("datamatrix_detection"), buff, sizeof(buff) - 1)) { - Serial.println(buff); - } -} - -void Camera::exe_barcode_detection(){ - char buff[128 + 1] = {}; // null terminator - if (interface->call_no_args(F("barcode_detection"), buff, sizeof(buff) - 1)) { - Serial.println(buff); - } -} bool Camera::exe_color_detection(int8_t l_min, int8_t l_max, int8_t a_min, int8_t a_max, int8_t b_min, int8_t b_max){ int8_t color_thresholds[6] = {l_min, l_max, a_min, a_max, b_min, b_max}; @@ -114,17 +85,20 @@ void Camera::exe_led_detection(){ } } -void Camera::exe_jpeg_snapshot(){ - - short buff[128 + 1] = {}; - Serial.println("looking for image"); - if (interface->call_no_args(F("jpeg_snapshot"), buff, sizeof(buff)-1)) { - Serial.println("Got JPEG"); - int i = 0; - while (buff[i] != '\0') { - Serial.print(buff[i]); - i++; - } - Serial.println(""); - } +bool Camera::exe_goalfinder(int goal1, int goal2, int goal3, int&id, int&tx, int&ty, int&tz, int&rx, int&ry, int&rz){ + int goalid[3] = {goal1, goal2, goal3}; + struct { uint16_t cid, ctx, cty, ctz, crx, cry, crz; } goalfinder_result; + interface->call(F("goalfinder"), goalid, sizeof(goalid), goalfinder_result, sizeof(goalfinder_result)); + if (goalfinder_result.crx == 0 && goalfinder_result.cry == 0){ + return false; + } else { + goalfinder.cid = id; + goalfinder.ctx = tx; + goalfinder.cty = ty; + goalfinder.ctz = tz; + goalfinder.crx = rx; + goalfinder.cry = ry; + goalfinder.crz = rz; + return true; + } } -- GitLab