Class Pixy2


  • public class Pixy2
    extends java.lang.Object
    Java Port of Pixy2 Arduino Library Interfaces with the Pixy2 over any provided, compatible link https://github.com/PseudoResonance/Pixy2JavaAPI
    • Method Detail

      • init

        public int init​(int argument)
        Initializes Pixy2 and waits for startup to complete
        Parameters:
        argument - Argument to setup Link
        Returns:
        Pixy2 error code
      • init

        public int init()
        Initializes Pixy2 and waits for startup to complete using default link argument value
        Returns:
        Pixy2 error code
      • createInstance

        public static Pixy2 createInstance​(Link link)
        Gets Pixy2 instance with supplied communication link
        Parameters:
        link - Communication Link to Pixy2
        Returns:
        Pixy2 instance
      • createInstance

        public static Pixy2 createInstance​(Pixy2.LinkType type)
        Gets Pixy2 instance with supplied communication link type
        Parameters:
        type - Communication Pixy2.LinkType to Pixy2
        Returns:
        Pixy2 instance
      • close

        public void close()
        Closes Pixy2
      • getCCC

        public Pixy2CCC getCCC()
        Get Pixy2 Color Connected Components tracker
        Returns:
        Pixy2 Color Connected Components tracker
      • getLine

        public Pixy2Line getLine()
        Get Pixy2 line tracker
        Returns:
        Pixy2 line tracker
      • getVideo

        public Pixy2Video getVideo()
        Get Pixy2 video tracker
        Returns:
        Pixy2 video tracker
      • getFrameWidth

        public int getFrameWidth()
        Get width of the pixy's visual frame after initialization
        Returns:
        Pixy2 Frame Width
      • getFrameHeight

        public int getFrameHeight()
        Get height of the pixy's visual frame after initialization
        Returns:
        Pixy2 Frame Height
      • getVersionInfo

        public Pixy2.Version getVersionInfo()
        Gets stored Pixy2 Pixy2.Version info or retrieves from Pixy2 if not present
        Returns:
        Pixy2 Version Info
      • receivePacket

        protected int receivePacket()
        Receives packet from Pixy2 and outputs to buffer for further processing
        Returns:
        Length of bytes received or Pixy2 error code
      • sendPacket

        protected int sendPacket()
        Sends packet to Pixy2 from buffer
        Returns:
        Length of bytes sent or Pixy2 error code
      • changeProg

        public byte changeProg​(char[] prog)
        Sends change program packet to Pixy2
        Parameters:
        prog - Program name
        Returns:
        Pixy2 error code
      • getVersion

        public int getVersion()
        Gets version info from Pixy2
        Returns:
        Buffer length or Pixy2 error code
      • getResolution

        public byte getResolution()
        Gets camera resolution from Pixy2
        Returns:
        Pixy2 error code
      • setCameraBrightness

        public byte setCameraBrightness​(int brightness)
        Sets Pixy2 camera brightness between 0-255
        Parameters:
        brightness - Byte representing camera brightness
        Returns:
        Pixy2 error code
      • setServos

        public byte setServos​(int pan,
                              int tilt)
        Sets Pixy2 servo positions between 0-1000
        Parameters:
        pan - Pan servo position
        tilt - Tilt servo position
        Returns:
        Pixy2 error code
      • setLED

        public byte setLED​(java.awt.Color color)
        Sets Pixy2 LED color to specified Color
        Parameters:
        color - Color
        Returns:
        Pixy2 error code
      • setLED

        public byte setLED​(int rgb)
        Sets Pixy2 LED color to specified RGB value
        Parameters:
        rgb - RGB value
        Returns:
        Pixy2 error code
      • setLED

        public byte setLED​(int r,
                           int g,
                           int b)
        Sets Pixy2 LED color to specified RGB values between 0-255
        Parameters:
        r - R value
        g - G value
        b - B value
        Returns:
        Pixy2 error code
      • setLamp

        public byte setLamp​(byte upper,
                            byte lower)
        Turns Pixy2 light source on/off Use 1 to indicate on, 0 to indicate off
        Parameters:
        upper - Byte indicating status of white LEDs
        lower - Byte indicating status of RGB LED
        Returns:
        Pixy2 error code
      • getFPS

        public byte getFPS()
        Gets Pixy2 camera framerate between 2-62fps
        Returns:
        Framerate or Pixy2 error code