samuelpowell / Spinnaker.jl

A Julia interface to the FLIR/PointGrey Spinnaker SDK
MIT License
15 stars 7 forks source link

Add control of autoexposure lighting and metering #58

Open IanButterworth opened 4 years ago

IanButterworth commented 4 years ago

This isn't working for me, but it may be a camera support issue, given neither AutoExposureLightingMode nor AutoExposureMeteringMode are present in spinview for my camera.

  autoexposure_lighting_mode!(::Camera, mode::String)

  Change autoexposure lighting mode.
  Options:
  - "AutoDetect": Automatically detect
  - "Backlight": Used when a strong light is coming from the back of the object.
  - "Frontlight": Used when a strong light is shining in the front of the object
                  while the background is dark.
  - "Normal": Used when the object is not under backlight or frontlight conditions
  autoexposure_metering_mode!(::Camera)

  Change autoexposure lighting mode to "Normal" and set the autoexposure metering mode.
  Options:
  - "Average": Measures the light from the entire scene uniformly to determine
                the final exposure value. Every portion of the exposed area has
                the same contribution.
  - "Spot": Measures a small area (about 3%) in the center of the scene while
                the rest of the scene is ignored. This mode is used when the
                scene has a high contrast and the object of interest is relatively
                small.
  - "Partial": Measures the light from a larger area (about 11%) in the center
                of the scene. This mode is used when very dark or bright regions
                appear at the edge of the frame.
  - "CenterWeighted": (No SDK docs)
  - "HistgramPeak": (No SDK docs)
IanButterworth commented 4 years ago

Some info: https://www.flir.com/support-center/iis/machine-vision/application-note/using-auto-exposure-in-blackfly-s/

samuelpowell commented 4 years ago

Okay in principle but how do I test this? Does it fail gracefully on an unsupported camera?

IanButterworth commented 4 years ago

It gives a spinnaker handle error for me

samuelpowell commented 4 years ago

Okay will check this when I'm in front of a camera

samuelpowell commented 4 years ago

Does the below match your expectations?

julia> autoexposure_lighting_mode!(cam1, "AutoDetect")
ERROR: Node AutoExposureLightingMode entry is not readable
Stacktrace:
 [1] set!(::Spinnaker.SpinEnumNode, ::String) at /Users/spowell/.julia/dev/Spinnaker/src/Nodes.jl:179
 [2] autoexposure_lighting_mode!(::Camera, ::String) at /Users/spowell/.julia/dev/Spinnaker/src/camera/acquisition.jl:164
 [3] top-level scope at REPL[7]:1

julia> autoexposure_lighting_mode!(cam1, "Backlight")
"Backlight"

julia> autoexposure_lighting_mode!(cam1, "Frontlight")
"Frontlight"

julia> autoexposure_lighting_mode!(cam1, "Normal")
"Normal"

julia> autoexposure_metering_mode!(cam1, "Average")
"Average"

julia> autoexposure_metering_mode!(cam1, "Spot")
"Spot"

julia> autoexposure_metering_mode!(cam1, "Partial")
"Partial"

julia> autoexposure_metering_mode!(cam1, "CenterWeighted")
ERROR: Node AutoExposureMeteringMode entry is not readable
Stacktrace:
 [1] set!(::Spinnaker.SpinEnumNode, ::String) at /Users/spowell/.julia/dev/Spinnaker/src/Nodes.jl:179
 [2] autoexposure_metering_mode!(::Camera, ::String) at /Users/spowell/.julia/dev/Spinnaker/src/camera/acquisition.jl:191
 [3] top-level scope at REPL[14]:1

julia> autoexposure_metering_mode!(cam1, "HistgramPeak")
ERROR: Node AutoExposureMeteringMode entry is not readable
Stacktrace:
 [1] set!(::Spinnaker.SpinEnumNode, ::String) at /Users/spowell/.julia/dev/Spinnaker/src/Nodes.jl:179
 [2] autoexposure_metering_mode!(::Camera, ::String) at /Users/spowell/.julia/dev/Spinnaker/src/camera/acquisition.jl:191
 [3] top-level scope at REPL[15]:1

julia> autoexposure_metering_mode!(cam1, "HistogramPeak")
┌ Error: Metering mode "HistogramPeak" not recognized
└ @ Spinnaker ~/.julia/dev/Spinnaker/src/camera/acquisition.jl:193

julia> autoexposure_metering_mode!(cam1, "Average")
"Average"
IanButterworth commented 4 years ago

It looks like the node names are recognized for your camera (which they aren’t for me) but that their function is locked because of another setting that needs to be switched first. Partial success. I’ll try to figure out which setting is blocking.