V5 Vision Sensor Signatures 4-7?

Hi, is there something special about vision signatures 4-7? Seems that only signatures 1-3 work as expected. I modified the c++ vision sample to have the same color green in sig 3 and sig 4 and only the one in 3 seems to trigger correctly.

How I got the signature was to place a green triball infront of the camera and use the configure utility in Vexcode, then copy the trained signature to the clipboard and added to the code. Here’s the output from the configure utility, and code following that.

vision::signature SIG_1 (1, -5113, -4239, -4676, -4311, -3567, -3938, 8.000, 0);
vision::signature SIG_2 (2, 0, 0, 0, 0, 0, 0, 2.500, 0);
vision::signature SIG_3 (3, 0, 0, 0, 0, 0, 0, 2.500, 0);
vision::signature SIG_4 (4, 0, 0, 0, 0, 0, 0, 2.500, 0);
vision::signature SIG_5 (5, 0, 0, 0, 0, 0, 0, 2.500, 0);
vision::signature SIG_6 (6, 0, 0, 0, 0, 0, 0, 2.500, 0);
vision::signature SIG_7 (7, 0, 0, 0, 0, 0, 0, 2.500, 0);
vex::vision vision1 ( vex::PORT1, 50, SIG_1, SIG_2, SIG_3, SIG_4, SIG_5, SIG_6, SIG_7 );
#pragma region VEXcode Generated Robot Configuration
// Make sure all required headers are included.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>


#include "vex.h"

using namespace vex;

// Brain should be defined by default
brain Brain;


// START V5 MACROS
#define waitUntil(condition)                                                   \
  do {                                                                         \
    wait(5, msec);                                                             \
  } while (!(condition))

#define repeat(iterations)                                                     \
  for (int iterator = 0; iterator < iterations; iterator++)
// END V5 MACROS


// Robot configuration code.




// Helper to make playing sounds from the V5 in VEXcode easier and
// keeps the code cleaner by making it clear what is happening.
void playVexcodeSound(const char *soundName) {
  printf("VEXPlaySound:%s\n", soundName);
  wait(5, msec);
}

#pragma endregion VEXcode Generated Robot Configuration


// ----------------------------------------------------------------------------
// 
//    Project:        Detecting Objects (Vision)
//    Description:    This project will detect 3 different colored objects
//                    and display when each object is found on the V5
//                    Brain's screen.
//    Configuration:  Vision5 on Port 5
// 
// ----------------------------------------------------------------------------

// Include the V5 Library
#include "vex.h"
  
// Allows for easier use of the VEX Library
using namespace vex;

vision::signature Vision8__BLUEBOX = vision::signature (1, -1489, -1091, -1290,13889, 14359, 14124,3, 0);
vision::signature Vision8__REDBOX = vision::signature (2, 12863, 15019, 13941,-345, 275, -35,3, 0);
vision::signature Vision8__GREENBOX = vision::signature (3, -5113, -4239, -4676, -4311, -3567, -3938, 8.000, 0);
vision::signature Vision8__GREENBOX4 = vision::signature (4, -5113, -4239, -4676, -4311, -3567, -3938, 8.000, 0);
vision Vision8 = vision (PORT8, 50, Vision8__BLUEBOX, Vision8__REDBOX, Vision8__GREENBOX, Vision8__GREENBOX4);

event checkGreen = event();
event checkGreen4 = event();

// Will check to see if there is a green object in view of the vision
// sensor and display the result on line 5 on the V5 Brain's screen
void hasGreenCallback() {
  Brain.Screen.clearLine(1);
  Brain.Screen.setCursor(1, 1);
  Vision8.takeSnapshot(Vision8__GREENBOX);
  if (Vision8.objectCount > 0) {
    Brain.Screen.print("Green SIG3 Object Found");
  } else {
    Brain.Screen.print("No Green SIG3 Object");
  }
}

void hasGreen4Callback() {
  Brain.Screen.clearLine(3);
  Brain.Screen.setCursor(3, 1);
  Vision8.takeSnapshot(Vision8__GREENBOX4);
  if (Vision8.objectCount > 0) {
    Brain.Screen.print("Green SIG4 Object Found");
  } else {
    Brain.Screen.print("No Green SIG4 Object");
  }
}

int main() {
  // register event handlers
  checkGreen(hasGreenCallback);
  checkGreen(hasGreen4Callback);

  // small delay to ensure that the event handlers are ready to be used
  wait(15, msec);

  // set the print font for all future prints to the V5 screen
  Brain.Screen.setFont(mono40);

  // constantly runs to check for new sensor data
  while (true) {
    checkGreen.broadcastAndWait();
    checkGreen4.broadcastAndWait();
    wait(0.1, seconds);
  }
}

No.

The algorithm will always match signature 3 before 4 if they have the same values. It doesn’t really make much sense to have two signatures with the same parameters.

1 Like

OK, so this was a contrived test case as I’ve been chasing this down for a while. Did not realize there was a priority order in the selection. The original issue was that I had 2 different green signatures and was testing between the two and not getting anything that seemed to make sense, but this explains it, thanks.

So coming back to this - what I’m trying to do is change the signatures during a program (ie make adjustments to the range, uMean, vMean for example). Is there a way of doing this? It doesn’t seem like any changes to the signature after the camera is instantiated seem to have any impact. I’m trying to run a localized search to optimize detection based on new lighting conditions without using the camera utility.

Ie if i insatiate the camera as follows:

vision MyVision = vision(PORT8, 50, Vision__SIG_1, Vision1__SIG_2, …);

then trying to call MyVision.takesnapshot(Vision_NewSignature) has no effect - that I can tell.

I’m guessing i’m looking for vision.setSignature(), although its under a section in the header “not part of current spec”. Will see if that works.

takeSnapshot is just a filtering function, the vision sensor would need to have a new signature set using setSignature for any updated signature to be detected by the sensor. It is an unusual use case and not something we usually test.

bool setSignature( signature &sig );

This would probably be easier with the new AI Vision sensor as the color descriptions it uses are more understandable.

1 Like

Thanks, yeah, checking every day to see when back in stock ;).

So setSignature() does the trick.

The plot below is what i was looking for which is basically a shmoo plot of detection outputs (ie triball count, x/y, size, etc.) vs. signature (u, v, range values, …).

This particular experiment was just with a single triball in shoddy lighting conditions and varying the signature.range of the green trained signature from 0.0 to 20.0. On the left are the square size of the detected triball and the variance, and the right is the count of the triball(s) and the variance (should only be one triball and variance of 0).

To be useful this would need to be run with no triball as well and a real measurement of the triball size based on camera placement. But at least it shows I’ve got the API calls getting some variation, which is what i wanted.

While chart is not calibrated, one conclusion would be that in current lighting the signature.range I’ve been using (8.0), is in a somewhat noisy section where small changes in the signature.range have a large change in detection quality.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.