เซ็นเซอร์ AI วิชั่น#

การแนะนำ#

คลาส aivision ใช้สำหรับควบคุมและเข้าถึงข้อมูลจากเซ็นเซอร์ AI Vision ของ EXP เซ็นเซอร์ AI Vision สามารถตรวจจับสิ่งต่อไปนี้ได้:

  • การจำแนกประเภทด้วย AI (เช่น วัตถุในเกม)

  • รหัสแท็กเดือนเมษายน

  • ลายเซ็นสีแบบกำหนดเอง

  • รหัสสีแบบกำหนดเอง

ระบบนี้ให้ข้อมูลเกี่ยวกับวัตถุ ได้แก่ ตำแหน่ง ขนาด การวางแนว รหัสจำแนกประเภท และคะแนนความน่าเชื่อถือ

เซ็นเซอร์จะประมวลผลข้อมูลภาพโดยใช้โมเดล AI ในตัวที่เลือกไว้ใน AI Vision Utility ภายใน VEXcode โมเดลที่เลือกจะกำหนดว่าเซ็นเซอร์สามารถตรวจจับการจำแนกประเภท AI ใดได้บ้าง เมื่อใช้ VS Code โมเดล AI จะต้องได้รับการกำหนดค่าใน VEXcode ก่อนจึงจะสามารถใช้งานในโปรแกรมของคุณได้ วัตถุที่ตรวจพบจะถูกส่งคืนผ่านอาร์เรย์ objects หลังจากเรียกใช้ takeSnapshot

ตัวสร้างคลาส#

aivision(
  int32_t index,
  Args&... sigs );

พารามิเตอร์#

พารามิเตอร์

พิมพ์

คำอธิบาย

index

int32_t

พอร์ตอัจฉริยะที่เชื่อมต่อกับเซ็นเซอร์ AI Vision จะเขียนในรูปแบบ PORTxโดยที่ x คือหมายเลขพอร์ต (ตัวอย่างเช่น PORT1)

sigs

colordesc, codedesc, or AI constants

ประเภทการตรวจจับอย่างน้อยหนึ่งประเภทที่จะลงทะเบียนกับเซ็นเซอร์:

  • aivision::ALL_AIOBJS — การจำแนกประเภท AI ทั้งหมด
  • aivision::ALL_TAGS — รหัส AprilTag ทั้งหมด
  • aivision::colordesc — ลายเซ็นสีแบบกำหนดเอง
  • aivision::codedesc — รหัสสีแบบกำหนดเอง

แบบจำลองและการจำแนกประเภทของ AI#

เซ็นเซอร์ AI Vision สามารถตรวจจับวัตถุต่างๆ ได้ด้วยการจำแนกประเภท AI ที่แตกต่างกัน ขึ้นอยู่กับโมเดลการจำแนกประเภท AI ที่เลือกเมื่อกำหนดค่าเซ็นเซอร์ AI Vision ในหน้าต่างอุปกรณ์ วัตถุที่สามารถตรวจจับได้จะแตกต่างกันไป โมเดลที่มีให้เลือกในปัจจุบัน ได้แก่:

องค์ประกอบในห้องเรียน

หมายเลขประจำตัว

การจำแนกประเภท AI

0

blueBall

1

greenBall

2

redBall

3

blueRing

4

greenRing

5

redRing

6

blueCube

7

greenCube

8

redCube

การแข่งขันหุ่นยนต์ VEX V5 เดิมพันสูง

หมายเลขประจำตัว

การจำแนกประเภท AI

0

mobileGoal

1

redRing

2

blueRing

เลื่อนการแข่งขันหุ่นยนต์ VEX V5 ออกไป

หมายเลขประจำตัว

การจำแนกประเภท AI

0

blueBlock

1

redBlock

การแข่งขันหุ่นยนต์ VEX V5 แบบพิเศษ

หมายเลขประจำตัว

การจำแนกประเภท AI

0

redBluePin

1

blueYellowPin

2

redYellowPin

3

yellowPin

4

cup

ตัวอย่าง#

// Create Color Signatures
aivision::colordesc AIVision1__greenBox(
    1,      // index
    85,     // red
    149,    // green
    46,     // blue
    23,     // hangle
    0.23 ); // hdsat

aivision::colordesc AIVision1__blueBox(
    2,      // index
    77,     // red
    135,    // green
    125,    // blue
    27,     // hangle
    0.29 ); // hdsat

// Create a Color Code from two color signatures
aivision::codedesc AIVision1__greenBlue(
    1,                    // code index
    AIVision1__greenBox,  // first color signature
    AIVision1__blueBox ); // second color signature

// Create the AI Vision Sensor instance
aivision AIVision1(
    PORT11,                  // Smart Port
    AIVision1__greenBlue,    // color code
    aivision::ALL_AIOBJS );  // enable AI Classifications

ฟังก์ชันสมาชิก#

คลาส aivision ประกอบด้วยฟังก์ชันสมาชิกต่อไปนี้:

  • takeSnapshot — บันทึกข้อมูลสำหรับลายเซ็นสี รหัสสี กลุ่มการจำแนกประเภท AI หรือกลุ่มรหัส AprilTag ที่เฉพาะเจาะจง

  • installed — ส่งคืนว่าเซ็นเซอร์ AI Vision เชื่อมต่อกับ EXP Brain หรือไม่

ในการเข้าถึงข้อมูลวัตถุที่ตรวจพบหลังจากเรียกใช้ takeSnapshot ให้ใช้ Properties ที่มีอยู่

ก่อนเรียกใช้ฟังก์ชันสมาชิก aivision ใดๆ จะต้องสร้างอินสแตนซ์ aivision ก่อน ดังแสดงด้านล่าง:

/* This constructor is required when using VS Code.
AI Vision Sensor configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */


// Create Color Signatures
aivision::colordesc AIVision1__greenBox(
    1,      // index
    85,     // red
    149,    // green
    46,     // blue
    23,     // hangle
    0.23 ); // hdsat

aivision::colordesc AIVision1__blueBox(
    2,      // index
    77,     // red
    135,    // green
    125,    // blue
    27,     // hangle
    0.29 ); // hdsat

// Create a Color Code from two color signatures
aivision::codedesc AIVision1__greenBlue(
    1,                    // code index
    AIVision1__greenBox,  // first color signature
    AIVision1__blueBox ); // second color signature

// Create the AI Vision Sensor instance
aivision AIVision1(
    PORT1,                   // Smart Port
    AIVision1__greenBlue,    // color code
    aivision::ALL_AIOBJS );  // enable AI Classifications

takeSnapshot#

จับภาพจากเซ็นเซอร์ AI Vision ประมวลผลโดยใช้โมเดล AI ที่เลือกหรือลายเซ็นสีที่กำหนดค่าไว้ และอัปเดตอาร์เรย์ objects

การเรียกแต่ละครั้งจะรีเฟรชอาร์เรย์ objects ด้วยผลการตรวจจับล่าสุด วัตถุจะถูกเรียงลำดับจากใหญ่ที่สุดไปเล็กที่สุด (ตามความกว้าง) โดยเริ่มจากดัชนี 0หากไม่พบวัตถุ objectCount จะเป็น 0 และ objects[i].exists จะเป็น false

1 — ถ่ายภาพสแนปช็อตโดยใช้รหัสวัตถุและประเภทวัตถุ

int32_t takeSnapshot(
  uint32_t id,
  objectType type,
  uint32_t count );

2 — ถ่ายภาพสแนปช็อตโดยใช้ ลายเซ็นสี

int32_t takeSnapshot(
  const colordesc &desc,
  int32_t count = 8 );

3 — ถ่ายภาพสแนปช็อตโดยใช้ รหัสสี

int32_t takeSnapshot(
  const codedesc &desc,
  int32_t count = 8 );

4 — ถ่ายภาพสแนปช็อตโดยใช้ AprilTag ID

int32_t takeSnapshot(
  const tagdesc &desc,
  int32_t count = 8 );

5 — ถ่ายภาพโดยใช้ การจำแนกประเภท AI

int32_t takeSnapshot(
  const aiobjdesc &desc,
  int32_t count = 8 );

6 — ถ่ายภาพสแนปช็อตโดยใช้ตัวอธิบายวัตถุ (Object Descriptor)

int32_t takeSnapshot(
  const objdesc &desc,
  int32_t count = 8 );

Parameters

พารามิเตอร์

พิมพ์

คำอธิบาย

id

uint32_t

ตัวระบุของวัตถุที่จะตรวจจับเมื่อใช้ฟังก์ชัน (id, type, count) ความหมายขึ้นอยู่กับ type:

  • colorObject — ดัชนีตัวอธิบายสี (1–7)
  • codeObject — ดัชนีรหัสสี (1–8)
  • modelObject — รหัสการจำแนกประเภท AI
  • tagObject — รหัส AprilTag (0–36)

หมายเหตุ: ใน VEXcode สามารถใช้ชื่อการจำแนกประเภท AI (เช่น blueBall) ได้โดยตรง ใน VS Code ต้องใช้รหัสตัวเลข

type

objectType

ระบุหมวดหมู่ของวัตถุที่เกี่ยวข้องกับ id:

desc

colordesc &, codedesc &, tagdesc &, aiobjdesc &, or objdesc &

Descriptor used to detect a specific object. Passed directly to takeSnapshot, for example:

  • AIVision1.takeSnapshot(AIVision1__greenBox);
  • AIVision1.takeSnapshot(aivision::ALL_AIOBJS);
Predefined descriptor constants:
  • aivision::ALL_TAGS — Detects all AprilTag IDs
  • aivision::ALL_COLORS — Detects all configured Color Signatures
  • aivision::ALL_CODES — Detects all configured Color Codes
  • aivision::ALL_AIOBJS — Detects all AI Classifications
  • aivision::ALL_OBJECTS — Detects everything the sensor can recognize

count

uint32_t / int32_t

จำนวนสูงสุดของวัตถุที่จัดเก็บจากสแนปช็อต ค่าเริ่มต้นคือ 8

ค่าที่ส่งคืน

ส่งคืนค่า int32_t ซึ่งแสดงจำนวนวัตถุที่ตรวจพบซึ่งตรงกับลายเซ็นหรือประเภทการตรวจจับที่ระบุ

หมายเหตุ

  • เซ็นเซอร์ AI Vision ต้องถ่ายภาพก่อนจึงจะสามารถเข้าถึงข้อมูลวัตถุได้

  • อาร์เรย์ objects จะได้รับการอัปเดตทุกครั้งที่มีการเรียกใช้งาน

  • เมื่อระบุค่า count ระบบจะจัดเก็บเฉพาะวัตถุที่ใหญ่ที่สุดที่ตรวจพบ (ไม่เกินจำนวนที่ระบุ) เท่านั้น

การจำแนกประเภทด้วย AI ขึ้นอยู่กับโมเดลที่เลือกใน AI Vision Utility ใน VEXcode

ตัวอย่าง

// Move forward if an object is detected
while (true) {
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);
  if (AIVision1.objects[0].exists) {
    Drivetrain.driveFor(forward, 50, mm);
  }
  wait(50, msec);
}

installed#

ตรวจสอบว่าเซ็นเซอร์ AI Vision เชื่อมต่อกับ EXP Brain แล้วหรือไม่

ฟังก์ชันที่ใช้งานได้

bool installed();

พารามิเตอร์

ฟังก์ชันนี้ไม่รับพารามิเตอร์ใดๆ

ค่าที่ส่งคืน

ส่งคืนค่าบูลีนที่ระบุว่าเซ็นเซอร์ AI Vision เชื่อมต่ออยู่หรือไม่:

  • true — เซ็นเซอร์ตรวจจับภาพ AI เชื่อมต่อแล้ว

  • false — เซ็นเซอร์ตรวจจับภาพ AI ไม่ได้เชื่อมต่อ

// Display a message if the AI Vision Sensor is connected
if (AIVision1.installed()){
  Brain.Screen.print("Installed!");
}

คุณสมบัติ#

การเรียก takeSnapshot จะอัปเดตผลการตรวจจับของ AI Vision Sensor แต่ละสแนปช็อตจะรีเฟรชอาร์เรย์ objects ซึ่งมีวัตถุที่ตรวจพบสำหรับการจำแนกประเภท AI ที่ร้องขอ, ลายเซ็นสี, รหัสสี หรือ AprilTag ID

ข้อมูล AI Vision สามารถเข้าถึงได้ผ่านคุณสมบัติของวัตถุที่จัดเก็บไว้ใน AIVisionSensor.objects[index]โดยที่ index เริ่มต้นที่ 0

วัตถุต่างๆ ถูกจัดเรียงจากขนาดใหญ่ที่สุดไปจนถึงขนาดเล็กที่สุด (ตามพื้นที่)

ความละเอียดภาพของเซ็นเซอร์ AI Vision 320 × 240 พิกเซลค่าตำแหน่งและขนาดของวัตถุจะถูกรายงานในหน่วยพิกเซลโดยสัมพันธ์กับมุมมองปัจจุบันของเซ็นเซอร์

ที่พักต่อไปนี้พร้อมให้บริการ:

  • objectCount — ส่งคืนจำนวนวัตถุที่ตรวจพบจากสแนปช็อตล่าสุด

  • largestObject — เลือกวัตถุที่ตรวจพบขนาดใหญ่ที่สุดจากสแนปช็อตล่าสุด

  • objects — อาร์เรย์ที่มีวัตถุที่ตรวจพบซึ่งได้รับการอัปเดตโดย takeSnapshot

  • .exists — ตรวจสอบว่ารายการวัตถุมีข้อมูลที่ถูกต้องหรือไม่

  • .width — ความกว้างของวัตถุที่ตรวจพบในหน่วยพิกเซล

  • .height — ความสูงของวัตถุที่ตรวจพบในหน่วยพิกเซล

  • .centerX — ตำแหน่ง X ของจุดศูนย์กลางของวัตถุในหน่วยพิกเซล

  • .centerY — ตำแหน่ง Y ของจุดศูนย์กลางของวัตถุในหน่วยพิกเซล

  • .originX — ตำแหน่ง X ของมุมบนซ้ายของวัตถุในหน่วยพิกเซล

  • .originY — ตำแหน่ง Y ของมุมบนซ้ายของวัตถุในหน่วยพิกเซล

  • .angle — การวางแนวของรหัสสีหรือรหัส AprilTag ในหน่วยองศา

  • .id — รหัสการจำแนกประเภทหรือรหัส AprilTag

  • .score — คะแนนความเชื่อมั่นสำหรับการจำแนกประเภท AI

objectCount#

objectCount ส่งคืนจำนวนรายการภายในอาร์เรย์ objects เป็นจำนวนเต็ม

Syntax
AIVisionSensor.objectCount

Components

ส่วนประกอบ

คำอธิบาย

AIVisionSensor

ชื่อของอินสแตนซ์ AI Vision Sensor ของคุณ

ตัวอย่าง

// Display the number of detected objects
while (true) {
  Brain.Screen.setCursor(1, 1);
  Brain.Screen.clearLine(1);
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);
  if (AIVision1.objects[0].exists) {
    Brain.Screen.print("%d", AIVision1.objectCount);
  }
  wait(50, msec);
}

largestObject#

largestObject ดึงวัตถุที่ใหญ่ที่สุดที่ตรวจพบจากอาร์เรย์ objects

วิธีนี้สามารถใช้เพื่อเลือกวัตถุที่ใหญ่ที่สุดจากวัตถุ objects โดยไม่ต้องระบุค่าดัชนี

Syntax
AIVisionSensor.largestObject

Components

ส่วนประกอบ

คำอธิบาย

AIVisionSensor

ชื่อของอินสแตนซ์ AI Vision Sensor ของคุณ

ตัวอย่าง

// Display the closest AprilTag ID
while (true) {
  Brain.Screen.setCursor(1, 1);
  Brain.Screen.clearLine(1);
  AIVision1.takeSnapshot(aivision::ALL_TAGS);
  if (AIVision1.objects[0].exists) {
    Brain.Screen.print("%d", AIVision1.largestObject.id);
  }
  wait(50, msec);
}

objects#

objects ส่งคืนอาร์เรย์ของคุณสมบัติวัตถุที่ตรวจพบ ใช้อาร์เรย์เพื่อเข้าถึงค่า คุณสมบัติ เฉพาะของวัตถุแต่ละชิ้น

มีคุณสมบัติสิบประการที่รวมอยู่ในแต่ละวัตถุที่เก็บไว้ในอาร์เรย์ objects หลังจากใช้ takeSnapshot

ค่าคุณสมบัติทั้งหมด ยกเว้น id และ score อธิบายตำแหน่งและขนาดของวัตถุที่ตรวจพบในมุมมองของเซ็นเซอร์ AI Vision ในขณะที่ takeSnapshot ถูกใช้งาน ค่าเหล่านี้วัดเป็นพิกเซล โดยอิงจากความละเอียด 320 x 240 พิกเซลของเซ็นเซอร์

Syntax
AIVisionSensor.objects[index].property

Components

ส่วนประกอบ

คำอธิบาย

AIVisionSensor

ชื่อของอินสแตนซ์ AI Vision Sensor ของคุณ

index

ดัชนีของวัตถุในอาร์เรย์ ดัชนีเริ่มต้นที่ 0

property

One of the available object properties.

มีอยู่จริง#

.exists

การเข้าถึง

SensorName.objects[index].exists

ค่าที่ส่งคืน

ส่งคืนค่าบูลีนที่ระบุว่าดัชนีวัตถุที่ระบุมีวัตถุที่ตรวจพบที่ถูกต้องหรือไม่:

  • true — A valid object exists at the specified index.
  • false — No object exists at the specified index.

ตัวอย่าง

// Move forward if an object is detected
while (true) {
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);
  if (AIVision1.objects[0].exists) {
    Drivetrain.driveFor(forward, 50, mm);
  }
  wait(50, msec);
}

.ความกว้าง#

.width ส่งคืนความกว้างของวัตถุที่ตรวจพบ

การเข้าถึง

SensorName.objects[index].width

ค่าที่ส่งคืน

ส่งคืนค่า int16_t ซึ่งแสดงถึงความกว้างของวัตถุที่ตรวจพบในหน่วยพิกเซล ค่าอยู่ในช่วงตั้งแต่ 1 ถึง 320

ตัวอย่าง

// Approach an object until it's at least 100 pixels wide
while (true) {
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);

  if (AIVision1.objects[0].exists) {
    if (AIVision1.objects[0].width < 100) {
      Drivetrain.drive(forward);
    } else {
      Drivetrain.stop();
    }
  } else {
    Drivetrain.stop();
  }
  wait(50, msec);
}

.ความสูง#

.height ส่งคืนความสูงของวัตถุที่ตรวจพบ

การเข้าถึง

SensorName.objects[index].height

ค่าที่ส่งคืน

ส่งคืนค่า int16_t ซึ่งแสดงถึงความสูงของวัตถุที่ตรวจพบในหน่วยพิกเซล ค่าอยู่ในช่วงตั้งแต่ 1 ถึง 240

ตัวอย่าง

// Approach an object until it's at least 90 pixels tall
while (true) {
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);

  if (AIVision1.objects[0].exists) {
    if (AIVision1.objects[0].height < 90) {
      Drivetrain.drive(forward);
    } else {
      Drivetrain.stop();
    }
  } else {
    Drivetrain.stop();
  }
  wait(50, msec);
}

.centerX#

.centerX ตรวจพบ

การเข้าถึง

SensorName.objects[index].centerX

ค่าที่ส่งคืน

ส่งคืนค่า int16_t ซึ่งแสดงพิกัด x ของจุดศูนย์กลางของวัตถุในหน่วยพิกเซล ค่าอยู่ในช่วงตั้งแต่ 0 ถึง 320

ตัวอย่าง

// Turn until an object is directly in front of the sensor
Drivetrain.setTurnVelocity(10, percent);
Drivetrain.turn(right);
while (true) {
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);

  if (AIVision1.objects[0].exists) {
    if (AIVision1.objects[0].centerX > 140 && AIVision1.objects[0].centerX < 180) {
      Drivetrain.stop();
    }
  }
  wait(10, msec);
}

.centerY#

.centerY ตรวจพบ

การเข้าถึง

SensorName.objects[index].centerY

ค่าที่ส่งคืน

ส่งคืนค่า int16_t ซึ่งแสดงพิกัด y ของจุดศูนย์กลางของวัตถุในหน่วยพิกเซล ค่าอยู่ในช่วงตั้งแต่ 0 ถึง 240

ตัวอย่าง

// Approach an object until it's close to the sensor
while (true) {
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);

  if (AIVision1.objects[0].exists) {
    if (AIVision1.objects[0].centerY < 150) {
      Drivetrain.drive(forward);
    } else {
      Drivetrain.stop();
    }
  } else {
    Drivetrain.stop();
  }
  wait(50, msec);
}

.มุม#

.angle ส่งคืนทิศทางของรหัสสีหรือรหัส AprilTag ที่ตรวจพบ

การเข้าถึง

SensorName.objects[index].angle

ค่าที่ส่งคืน

Returns a float representing the rotation of the detected Color Code or AprilTag ID in degrees. The value ranges from 0 to 359.9.

ตัวอย่าง

// Turn left or right depending on how a configured
// Color Code is rotated
while (true) {
  AIVision1.takeSnapshot(AIVision1__redBlue);
  if (AIVision1.objects[0].exists) {
    if (AIVision1.objects[0].angle > 50 && AIVision1.objects[0].angle < 100) {
      Drivetrain.turn(right);
    }
    else if (AIVision1.objects[0].angle > 270 && AIVision1.objects[0].angle < 330) {
      Drivetrain.turn(left);
    }
    else {
      Drivetrain.stop();
    }
  } else {
    Drivetrain.stop();
  }
  wait(50, msec);
}

.originX#

.originX จะส่งคืนค่าพิกัด x ของมุมบนซ้ายของกรอบล้อมรอบวัตถุที่ตรวจพบ

การเข้าถึง

SensorName.objects[index].originX

ค่าที่ส่งคืน

ส่งคืนค่า int16_t ซึ่งแสดงพิกัด x ของจุดกำเนิดของกรอบล้อมรอบวัตถุในหน่วยพิกเซล ค่าอยู่ในช่วงตั้งแต่ 0 ถึง 320

ตัวอย่าง

// Display if an object is to the left or the right
while (true) {
  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1, 1);
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);
  if (AIVision1.objects[0].exists) {
    if (AIVision1.objects[0].originX < 120) {
      Brain.Screen.print("To the left!");
    } else {
      Brain.Screen.print("To the right!");
    }
  } else {
    Brain.Screen.print("No objects");
  }
  wait(100, msec);
}

.originY#

.originY จะส่งคืนค่าพิกัด y ของมุมบนซ้ายของกรอบล้อมรอบวัตถุที่ตรวจพบ

การเข้าถึง

SensorName.objects[index].originY

ค่าที่ส่งคืน

ส่งคืนค่า int16_t ซึ่งแสดงพิกัด y ของจุดกำเนิดกรอบล้อมรอบวัตถุในหน่วยพิกเซล ค่าอยู่ในช่วงตั้งแต่ 0 ถึง 240

ตัวอย่าง

// Display if an object is close or far
while (true) {
  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1, 1);
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);
  if (AIVision1.objects[0].exists) {
    if (AIVision1.objects[0].originY < 110) {
      Brain.Screen.print("Close");
    } else {
      Brain.Screen.print("Far");
    }
  }
  wait(100, msec);
}

.id#

.id ส่งคืน AprilTag ID หรือ AI Classification ID ที่ตรวจพบ

การเข้าถึง

SensorName.objects[index].id

ค่าที่ส่งคืน

ส่งคืนค่า int32_t ซึ่งแสดงถึง ID ของวัตถุที่ตรวจพบ:

ตัวอย่าง

// Move forward when AprilTag ID 1 is detected
while (true) {
  AIVision1.takeSnapshot(aivision::ALL_TAGS);
  if (AIVision1.objects[0].exists) {
    if (AIVision1.objects[0].id == 1) {
      Drivetrain.drive(forward);
    }
  } else {
    Drivetrain.stop();
  }
  wait(50, msec);
}

.คะแนน#

.score จะส่งคืนค่าคะแนนความเชื่อมั่นของการจำแนกประเภท AI ที่ตรวจพบ

การเข้าถึง

SensorName.objects[index].score

ค่าที่ส่งคืน

ส่งคืนค่า int16_t ซึ่งระบุคะแนนความเชื่อมั่นของการจำแนกประเภท AI ที่ตรวจพบ โดยมีค่าอยู่ระหว่าง 1 ถึง 100

คะแนนที่ต่ำกว่าหมายความว่าเซ็นเซอร์มีความมั่นใจน้อยลงในการตรวจจับวัตถุ ในขณะที่คะแนนที่สูงกว่าหมายความว่าเซ็นเซอร์มีความมั่นใจมากขึ้น

ตัวอย่าง

// Display if a score is confident
while (true) {
  AIVision1.takeSnapshot(aivision::ALL_AIOBJS);

  if (AIVision1.objects[0].exists) {
    Brain.screen.clearScreen();
    Brain.screen.setCursor(1, 1);

    if (AIVision1.objects[0].score > 95) {
      Brain.Screen.print("Confident");
    } else {
      Brain.Screen.print("Not confident");
    }
  }
  wait(50, msec);
}