Does anybody have sample code of sending serial messages to the roboRIO from the JeVois?

My team was counting on getting a Limelight, which is way easier to program, but now they are sold out again before we could order one.

Here’s my code, heavily edited to eliminate things that aren’t related to Serial processing

import libjevois as jevois
import cv2
import numpy as np

x

Add some description of your module here.

@author DAve

@videomapping YUYV 640 480 30 YUYV 640 480 30 X Sandbox2

@email none

########## Code that isn’t related to the serial port has been deleted

class Sandbox2:

# ###################################################################################################
## Process function with no USB output
def processNoUSB(self, inframe):
    # Get the next camera image (may block until it is captured) and here convert it to OpenCV BGR. If you need a
    # grayscale image, just use getCvGRAY() instead of getCvBGR(). Also supported are getCvRGB() and getCvRGBA():
    inimg = inframe.getCvBGR()

    # Start measuring image processing time (NOTE: does not account for input conversion time):
    self.timer.start()
    
    jevois.LINFO("Processing video frame {} now...".format(self.frame))

    # TODO: you should implement some processing.
    # Once you have some results, send serial output messages:

    # Get frames/s info from our timer:
    fps = self.timer.stop()

    # Send a serial output message:
    jevois.sendSerial("DONE frame nousb {} - {}".format(self.frame, fps));
    self.frame += 1
    
# ###################################################################################################
## Process function with USB output
def process(self, inframe, outframe):
     # Get the next camera image (may block until it is captured) and here convert it to OpenCV BGR. If you need a
    # grayscale image, just use getCvGRAY() instead of getCvBGR(). Also supported are getCvRGB() and getCvRGBA():
    inimg = inframe.getCvBGR()
    
    # Start measuring image processing time (NOTE: does not account for input conversion time):
    self.timer.start()
Deleted a bunch of code meant to look for the orange cargo balls.
        if biggest<20:
        jevois.sendSerial("No ball found this cycle")
    else:
       x,y,w,h=cv2.boundingRect(cnt)
       centerX=(x+w/2)-320
       jevois.sendSerial("Center X: "+str(centerX))
  
    self.frame += 1

################################

When running in headless mode, the function ProcessNoUSB is called (so that is where the actual vision processing ought to go). When running in “regular” mode, such as when you first plug into Inventor, the Process function is called.

Here are the contents of the config file.

setmapping2 YUYV 640 480 30.0 Lame Sandbox2

setpar serout USB

streamon

####################################
As noted in the comments section, this was intended to detect balls, specifically the orange cargo balls. It isn’t working. The colors are all messed up, so the settings that work well in Grip don’t work worth a darn on the Jevois, even though I set up my vision parameters by running the Jevois into Grip.

Still working on that problem. I hope to use Jevois, but right now the color problem is so bad I’m finding it unusable. Presumably it’s some form of operator error, but I’m banging my head against the wall.

ETA: It seems that something I pasted from my code was interpreted by ChiefDelphi’s code as some special sequence, and some of the code formatting got really weird. If you can’t read my pasted code, let me know and I can try again.