Skip to content
firepick1 (pixel) edited this page Oct 8, 2014 · 10 revisions

Computer Vision Configuration

Smart camera nodes declare and define a FireREST™ CV computer vision service via the cv JSON object.

Example

{ "FireREST":{"title":"Raspberry Pi FireFUSE","provider":"FireFUSE"},
  "cv":{
    "cve_map":{
      "calc-offset":{
	"firesight": [
	  {"op":"calcOffset", "name":"model", "minval":0.7, "roi":[350,50,100,100],
	    "xtol":32, "ytol":32, "channels":[], "template":"{{saved}}" },
	  {"op":"drawRects", "model":"model", "color":[32,255,32]}
	]
      },
      "locate-part":{
	"firesight": [
	  {"op":"absdiff", "path":"{{saved}}"},
	  {"op":"threshold", "type":"{{type}}", "thresh":"{{thresh}}", "maxval":"{{maxval}}"},
	  {"op":"morph", "ksize":"{{ksize}}", "mop":"{{mop}}", "iterations":"{{iterations}}", "shape":"{{shape}}"},
	  {"op":"minAreaRect", "name":"singleBlob", "min":"{{min}}", "max":"{{max}}", "channel":"{{channel}}"},
	  {"op":"stageImage", "stage":"input"},
	  {"op":"drawRects", "model":"singleBlob", "thickness":"{{thickness}}", "color":"{{color||[255,0,255]}}"}
	]
      }
    },
    "camera_map":{
      "1":{
	"width":800,
	"height":200,
	"profile_map":{
	  "gray":{ "cve_names":[ "calc-offset", "locate-part" ] },
	  "bgr":{ "cve_names":[ "calc-offset", "locate-part" ] }
	}
      }
    }
  }
}

Reference

cv

Maps to the definition of a computer vision service. Example:

"cv":{
  "maxfps":1.4,
  "cve_map":{ ... },
  "camera_map":{ ... }
}

maxfps

Image acquistion is handled by raspistill, the standard Raspberry Pi still camera. For pick-and-place use cases, it's critical to have up-to-date images so that we can use vision to coordinate motion. We trigger image capture by sending SIGUSR1 to raspistill to save the image to /dev/firefuse/cv/1/camera.jpg. Empirically, we have learned that raspistill freezes up when these signals are sent too frequently. As a result, FireFUSE throttles the number of captures using maxfps, which is "maximum frames per second":

  • maxfps 1.4 Overclock HIGH (Default)
  • maxfps 2.5 Overclock TURBO
"cv":{
  "maxfps":1.4,
   ...
}

cve_map

Maps to a JSON object whose attributes name and define the CVEs provided by the vision recognition service. CVEs can be shared amongst camera profiles, which bind to CVEs by their name. There is no limit to the number of CVEs you can define, and it is best practice to define a CVE for each particular use case (e.g., "calc-offset-feeder-1-tape-1"). Example:

"cve_map": {
"calc-offset":{ ... },
"locate-part":{ ... }
}
}

cve_name

Maps to a JSON object that defines the CVE. CVE names should be URL friendly. Example:

"calc-offset":{
  "firesight": [ ... ]
}

firesight

Maps to a JSON array that defines the FireSight pipeline. Example:

"firesight": [
  {"op":"calcOffset", "name":"model", "minval":0.7, "roi":[350,50,100,100],
    "xtol":32, "ytol":32, "channels":[], "template":"{{saved}}" },
  {"op":"drawRects", "model":"model", "color":[32,255,32]}
]

camera_map

Maps to a JSON object whose attributes name and define the camera(s) provided by the vision recognition service. Camera names should be URL friendly. Example:

"camera_map":{
  "1":{ ... }
}

camera_name

Maps to a JSON object that defines a camera by its width, height and profiles. Example:

"1":{
  "width":800,
  "height":200,
  "profile_map":{ ... }
}

height

Pixel height of camera image

"height":200

width

Pixel width of camera image

"width":800

profile_map

Maps to a JSON object whose attributes name and define the profile(s) provided by the camera. Example:

"profile_map":{
  "gray":{ "cve_names":[ "calc-offset", "locate-part" ] },
  "bgr":{ "cve_names":[ "calc-offset", "locate-part" ] }
}

profile_name

Maps to a JSON object that defines the profile. Profile names should be URL friendly. Example:

"gray":{ "cve_names":[ "calc-offset", "locate-part" ] }

cve_names

Maps to a JSON array that names the CVEs used in the profile. Example:

"cve_names":[ "calc-offset", "locate-part" ] 

See Also