Setting Up and Using Vision Sensor for Reporting Object Position

  1. 2 weeks ago
    Edited 2 weeks ago by Ben.162A

    I am trying to write some flag tracking code in VCS. Right now I'm just trying to figure out how to get values for the position of an object in the sensor's field of view from the vision sensor in real time. Here is my code. What am I doing wrong?

    Here is the robot-config.h

    vex::brain Brain;
    vex::vision::signature RED_FLAGL (1, 8977, 10189, 9583, -1867, -1037, -1452, 3.700000047683716, 0);
    vex::vision::signature BLUE_FLAGL (2, -4445, -3827, -4136, 8403, 9909, 9156, 6.400000095367432, 0);
    vex::vision::signature SIG_3 (3, 0, 0, 0, 0, 0, 0, 3, 0);
    vex::vision::signature SIG_4 (4, 0, 0, 0, 0, 0, 0, 3, 0);
    vex::vision::signature SIG_5 (5, 0, 0, 0, 0, 0, 0, 3, 0);
    vex::vision::signature SIG_6 (6, 0, 0, 0, 0, 0, 0, 3, 0);
    vex::vision::signature SIG_7 (7, 0, 0, 0, 0, 0, 0, 3, 0);
    vex::vision flagFinderL (vex::PORT9, 150, RED_FLAGL, BLUE_FLAGL, SIG_3, SIG_4, SIG_5, SIG_6, SIG_7);

    Here is the main code:

    #include "robot-config.h"

    int main() {
    while (true){
    Brain.Screen.clearScreen(vex::color::black);
    flagFinderL.takeSnapshot(RED_FLAGL);
    Brain.Screen.setFont(vex::fontType::mono40);
    Brain.Screen.setCursor(1,1);
    Brain.Screen.print("%d", flagFinderL.largestObject.centerY);
    Brain.Screen.render();
    vex::task::sleep(10);
    }
    }

  2. 3038922

    Jan 2 china ares

    Considering the complexity of the field light source, vision can not exert its practical ability with our current technology.

  3. tabor473

    Jan 2 V5 Beta Tester Salt Lake City OYES, WPI

    @3038922 Considering the complexity of the field light source, vision can not exert its practical ability with our current technology.

    Wow that is not really a helpful answer for the OP, who was asking an API question.

  4. josh_siegel

    Jan 3 Davis, California 162A Mentor/Alumni

    @jpearman

  5. jpearman

    Jan 3 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888
    Edited 2 weeks ago by jpearman

    @josh_siegel @jpearman

    Er, yes ??
    I don't see anything particularly wrong. (except there's really no need to call Brain.Screen.render(), but that's not relevant to the question).

    and also, 150 for brightness seems really high, usually I see values around 50.

  6. josh_siegel

    Jan 3 Davis, California 162A Mentor/Alumni

    @jpearman thanks for the response! I had no clue either

 

or Sign Up to reply!