DeepSpace  2019
__main__ Namespace Reference

Classes

class  CameraConfig
 
class  FPS
 
class  VideoShow
 
class  WebcamVideoStream
 

Functions

def flipImage (frame)
 
def blurImg (frame, blur_radius)
 
def threshold_range (im, lo, hi)
 
def threshold_video (lower_color, upper_color, blur)
 
def findTargets (frame, mask)
 
def findCargo (frame, mask)
 
def findHatch (frame, mask)
 
def findBall (contours, image, centerX, centerY)
 
def findHatches (contours, image, centerX, centerY)
 
def findTape (contours, image, centerX, centerY)
 
def checkContours (cntSize, hullSize)
 
def checkBall (cntSize, cntAspectRatio)
 
def checkHatch (cntSize, cntAspectRatio)
 
def translateRotation (rotation, width, height)
 
def calculateDistance (heightOfCamera, heightOfTarget, pitch)
 
def calculateDistWPILib (cntHeight)
 
def calculateYaw (pixelX, centerX, hFocalLength)
 
def calculatePitch (pixelY, centerY, vFocalLength)
 
def getEllipseRotation (image, cnt)
 
def parseError (str)
 
def readCameraConfig (config)
 
def readConfig ()
 
def startCamera (config)
 
def switchCam ()
 

Variables

int frameStop = 0
 
int ImageCounter = 0
 
int image_width = 416
 
int image_height = 240
 
 diagonalView = math.radians(68.5)
 
int horizontalAspect = 16
 
int verticalAspect = 9
 
 diagonalAspect = math.hypot(horizontalAspect, verticalAspect)
 
int horizontalView = math.atan(math.tan(diagonalView / 2) * (horizontalAspect / diagonalAspect)) * 2
 
int verticalView = math.atan(math.tan(diagonalView / 2) * (verticalAspect / diagonalAspect)) * 2
 
int H_FOCAL_LENGTH = image_width / (2 * math.tan((horizontalView / 2)))
 
int V_FOCAL_LENGTH = image_height / (2 * math.tan((verticalView / 2)))
 
int green_blur = 1
 
int orange_blur = 27
 
int yellow_blur = 27
 
 lower_green = np.array([40, 75, 75])
 
 upper_green = np.array([96, 255, 255])
 
 lower_orange = np.array([0, 193, 92])
 
 upper_orange = np.array([23, 255, 255])
 
 lower_yellow = np.array([36, 50, 80])
 
 upper_yellow = np.array([55, 120, 120])
 
int switch = 1
 
list avg = [0 for i in range(0, 8)]
 
string configFile = "/boot/frc.json"
 FRC VISION PI Image Specific #############. More...
 
int team = 5024
 
bool server = True
 
list cameraConfigs = []
 
int currentCam = 0
 
 ntinst = NetworkTablesInstance.getDefault()
 
 networkTable = NetworkTables.getTable('ChickenVision')
 
 networkTableMatch = NetworkTables.getTable("FMSInfo")
 
list cameras = []
 
list streams = []
 
 cs
 
 cameraCapture
 
list webcam = cameras[currentCam]
 
list cameraServer = streams[currentCam]
 
 cap = WebcamVideoStream(webcam, cameraServer, image_width, image_height).start()
 
 img = np.zeros(shape=(image_height, image_width, 3), dtype=np.uint8)
 
 streamViewer = VideoShow(image_width, image_height, cameraServer, frame=img).start()
 
bool tape = True
 
 fps = FPS().start()
 
 matchNumberDefault = random.randint(1, 1000)
 
int processed = 0
 
 timestamp
 
 matchNumber = networkTableMatch.getNumber("MatchNumber", 0)
 
def frame = flipImage(img)
 
bool switched = True
 
bool start = False
 
def threshold = threshold_video(lower_green, upper_green, frame)
 
def boxBlur = blurImg(frame, orange_blur)
 
int k = cv2.waitKey(60) & 0xff
 

Function Documentation

◆ blurImg()

def __main__.blurImg (   frame,
  blur_radius 
)

Definition at line 226 of file __main__.py.

◆ calculateDistance()

def __main__.calculateDistance (   heightOfCamera,
  heightOfTarget,
  pitch 
)

Definition at line 753 of file __main__.py.

◆ calculateDistWPILib()

def __main__.calculateDistWPILib (   cntHeight)

Definition at line 780 of file __main__.py.

◆ calculatePitch()

def __main__.calculatePitch (   pixelY,
  centerY,
  vFocalLength 
)

Definition at line 824 of file __main__.py.

◆ calculateYaw()

def __main__.calculateYaw (   pixelX,
  centerX,
  hFocalLength 
)

Definition at line 818 of file __main__.py.

◆ checkBall()

def __main__.checkBall (   cntSize,
  cntAspectRatio 
)

Definition at line 736 of file __main__.py.

◆ checkContours()

def __main__.checkContours (   cntSize,
  hullSize 
)

Definition at line 730 of file __main__.py.

◆ checkHatch()

def __main__.checkHatch (   cntSize,
  cntAspectRatio 
)

Definition at line 739 of file __main__.py.

◆ findBall()

def __main__.findBall (   contours,
  image,
  centerX,
  centerY 
)

Definition at line 332 of file __main__.py.

◆ findCargo()

def __main__.findCargo (   frame,
  mask 
)

Definition at line 294 of file __main__.py.

◆ findHatch()

def __main__.findHatch (   frame,
  mask 
)

Definition at line 311 of file __main__.py.

◆ findHatches()

def __main__.findHatches (   contours,
  image,
  centerX,
  centerY 
)

Definition at line 435 of file __main__.py.

◆ findTape()

def __main__.findTape (   contours,
  image,
  centerX,
  centerY 
)

Definition at line 541 of file __main__.py.

◆ findTargets()

def __main__.findTargets (   frame,
  mask 
)

Definition at line 267 of file __main__.py.

◆ flipImage()

def __main__.flipImage (   frame)

Definition at line 221 of file __main__.py.

◆ getEllipseRotation()

def __main__.getEllipseRotation (   image,
  cnt 
)

Definition at line 831 of file __main__.py.

◆ parseError()

def __main__.parseError (   str)
Report parse error.

Definition at line 879 of file __main__.py.

◆ readCameraConfig()

def __main__.readCameraConfig (   config)

Definition at line 886 of file __main__.py.

◆ readConfig()

def __main__.readConfig ( )

Definition at line 912 of file __main__.py.

◆ startCamera()

def __main__.startCamera (   config)

Definition at line 962 of file __main__.py.

◆ switchCam()

def __main__.switchCam ( )

Definition at line 975 of file __main__.py.

◆ threshold_range()

def __main__.threshold_range (   im,
  lo,
  hi 
)

Definition at line 231 of file __main__.py.

◆ threshold_video()

def __main__.threshold_video (   lower_color,
  upper_color,
  blur 
)

Definition at line 240 of file __main__.py.

◆ translateRotation()

def __main__.translateRotation (   rotation,
  width,
  height 
)

Definition at line 744 of file __main__.py.

Variable Documentation

◆ avg

list __main__.avg = [0 for i in range(0, 8)]

Definition at line 778 of file __main__.py.

◆ boxBlur

def __main__.boxBlur = blurImg(frame, orange_blur)

Definition at line 1137 of file __main__.py.

◆ cameraCapture

__main__.cameraCapture

Definition at line 1014 of file __main__.py.

◆ cameraConfigs

list __main__.cameraConfigs = []

Definition at line 874 of file __main__.py.

◆ cameras

list __main__.cameras = []

Definition at line 1011 of file __main__.py.

◆ cameraServer

list __main__.cameraServer = streams[currentCam]

Definition at line 1020 of file __main__.py.

◆ cap

Definition at line 1022 of file __main__.py.

◆ configFile

__main__.configFile = "/boot/frc.json"

FRC VISION PI Image Specific #############.

Definition at line 866 of file __main__.py.

◆ cs

__main__.cs

Definition at line 1014 of file __main__.py.

◆ currentCam

int __main__.currentCam = 0

Definition at line 973 of file __main__.py.

◆ diagonalAspect

__main__.diagonalAspect = math.hypot(horizontalAspect, verticalAspect)

Definition at line 194 of file __main__.py.

◆ diagonalView

__main__.diagonalView = math.radians(68.5)

Definition at line 187 of file __main__.py.

◆ fps

__main__.fps = FPS().start()

Definition at line 1032 of file __main__.py.

◆ frame

__main__.frame = flipImage(img)

Definition at line 1071 of file __main__.py.

◆ frameStop

int __main__.frameStop = 0

Definition at line 176 of file __main__.py.

◆ green_blur

int __main__.green_blur = 1

Definition at line 203 of file __main__.py.

◆ H_FOCAL_LENGTH

int __main__.H_FOCAL_LENGTH = image_width / (2 * math.tan((horizontalView / 2)))

Definition at line 200 of file __main__.py.

◆ horizontalAspect

int __main__.horizontalAspect = 16

Definition at line 190 of file __main__.py.

◆ horizontalView

int __main__.horizontalView = math.atan(math.tan(diagonalView / 2) * (horizontalAspect / diagonalAspect)) * 2

Definition at line 196 of file __main__.py.

◆ image_height

int __main__.image_height = 240

Definition at line 183 of file __main__.py.

◆ image_width

int __main__.image_width = 416

Definition at line 182 of file __main__.py.

◆ ImageCounter

int __main__.ImageCounter = 0

Definition at line 177 of file __main__.py.

◆ img

__main__.img = np.zeros(shape=(image_height, image_width, 3), dtype=np.uint8)

Definition at line 1026 of file __main__.py.

◆ k

int __main__.k = cv2.waitKey(60) & 0xff

Definition at line 1171 of file __main__.py.

◆ lower_green

__main__.lower_green = np.array([40, 75, 75])

Definition at line 208 of file __main__.py.

◆ lower_orange

__main__.lower_orange = np.array([0, 193, 92])

Definition at line 211 of file __main__.py.

◆ lower_yellow

__main__.lower_yellow = np.array([36, 50, 80])

Definition at line 214 of file __main__.py.

◆ matchNumber

__main__.matchNumber = networkTableMatch.getNumber("MatchNumber", 0)

Definition at line 1064 of file __main__.py.

◆ matchNumberDefault

__main__.matchNumberDefault = random.randint(1, 1000)

Definition at line 1045 of file __main__.py.

◆ networkTable

__main__.networkTable = NetworkTables.getTable('ChickenVision')

Definition at line 999 of file __main__.py.

◆ networkTableMatch

__main__.networkTableMatch = NetworkTables.getTable("FMSInfo")

Definition at line 1001 of file __main__.py.

◆ ntinst

__main__.ntinst = NetworkTablesInstance.getDefault()

Definition at line 997 of file __main__.py.

◆ orange_blur

int __main__.orange_blur = 27

Definition at line 204 of file __main__.py.

◆ processed

def __main__.processed = 0

Definition at line 1049 of file __main__.py.

◆ server

bool __main__.server = True

Definition at line 873 of file __main__.py.

◆ start

bool __main__.start = False

Definition at line 1094 of file __main__.py.

◆ streams

list __main__.streams = []

Definition at line 1012 of file __main__.py.

◆ streamViewer

__main__.streamViewer = VideoShow(image_width, image_height, cameraServer, frame=img).start()

Definition at line 1028 of file __main__.py.

◆ switch

int __main__.switch = 1

Definition at line 217 of file __main__.py.

◆ switched

bool __main__.switched = True

Definition at line 1092 of file __main__.py.

◆ tape

bool __main__.tape = True

Definition at line 1031 of file __main__.py.

◆ team

int __main__.team = 5024

Definition at line 872 of file __main__.py.

◆ threshold

def __main__.threshold = threshold_video(lower_green, upper_green, frame)

Definition at line 1126 of file __main__.py.

◆ timestamp

__main__.timestamp

Definition at line 1062 of file __main__.py.

◆ upper_green

__main__.upper_green = np.array([96, 255, 255])

Definition at line 209 of file __main__.py.

◆ upper_orange

__main__.upper_orange = np.array([23, 255, 255])

Definition at line 212 of file __main__.py.

◆ upper_yellow

__main__.upper_yellow = np.array([55, 120, 120])

Definition at line 215 of file __main__.py.

◆ V_FOCAL_LENGTH

int __main__.V_FOCAL_LENGTH = image_height / (2 * math.tan((verticalView / 2)))

Definition at line 201 of file __main__.py.

◆ verticalAspect

int __main__.verticalAspect = 9

Definition at line 191 of file __main__.py.

◆ verticalView

int __main__.verticalView = math.atan(math.tan(diagonalView / 2) * (verticalAspect / diagonalAspect)) * 2

Definition at line 197 of file __main__.py.

◆ webcam

list __main__.webcam = cameras[currentCam]

Definition at line 1019 of file __main__.py.

◆ yellow_blur

int __main__.yellow_blur = 27

Definition at line 205 of file __main__.py.