Adapters: add Meet, Zoom, Teams (coloured border) + adapter registry
Front-loads the remaining visual adapters per the Signal→Meet→Zoom priority. All three reuse GridCallAnalyzer's coloured-border (saturated) detection path and share the new bottom-left name anchor: - GridCallAnalyzer: generalise nameAtBottom:Bool into a NameAnchor enum (.bottomCenter for Signal's centered footer, .bottomLeft for Meet/Zoom/Teams where the name hugs the tile's bottom-left corner, .center for completeness). tileRect estimates the tile up-and-right of a bottom-left name. - MeetAdapter (Google-blue ring, browser-hosted), ZoomAdapter (green/yellow border), TeamsAdapter (violet ring): coloured-border on, white-border off, bottom-left names. Geometry constants are first-pass pending real fixtures. - AdapterRegistry.adapter(for:) maps CallDetector.DetectedApp → AppAdapter so VisualObserver can be constructed when live visual capture is wired in; unmapped apps degrade to audio-only. Synthetic 4-tile tests: Meet picks each blue-bordered speaker with no adjacent-tile bleed, Zoom picks the green-bordered speaker, and Signal's white-only detector correctly ignores a coloured border. 18/18 XCTest pass.
This commit is contained in:
@@ -13,10 +13,18 @@ import CoreImage
|
||||
/// Geometry (`Config`) is a first pass; tile expansion calibrates per app against
|
||||
/// real screenshot fixtures. Detection *logic* is validated on synthetic frames.
|
||||
struct GridCallAnalyzer {
|
||||
/// Where the name label sits relative to its participant tile — drives how the
|
||||
/// tile rect is estimated from the OCR'd name box.
|
||||
enum NameAnchor {
|
||||
case bottomCenter // Signal: centered footer; tile extends UP, centered on the name
|
||||
case bottomLeft // Meet/Zoom: name in the bottom-left corner; tile extends UP and RIGHT
|
||||
case center // name centered inside the tile
|
||||
}
|
||||
|
||||
struct Config {
|
||||
var tileExpandX = 2.4 // tile width ≈ name width × this
|
||||
var tileExpandY = 4.8 // tile height ≈ name height × this
|
||||
var nameAtBottom = true // Signal/most: name footer sits at the tile bottom
|
||||
var nameAnchor: NameAnchor = .bottomCenter
|
||||
var detectColoredBorder = true
|
||||
var detectWhiteBorder = true
|
||||
var minTextConfidence: Float = 0.3
|
||||
@@ -91,20 +99,27 @@ struct GridCallAnalyzer {
|
||||
return CGRect(x: box.minX * W, y: (1 - box.maxY) * H, width: box.width * W, height: box.height * H)
|
||||
}
|
||||
|
||||
/// Estimate the participant tile from the name label. With `nameAtBottom`, the
|
||||
/// tile extends UP from the footer (Signal); otherwise it's centred on the name.
|
||||
/// Estimate the participant tile from the name label, per the app's `nameAnchor`:
|
||||
/// - `.bottomCenter` (Signal): tile extends UP from a centered footer.
|
||||
/// - `.bottomLeft` (Meet/Zoom): name hugs the tile's bottom-left corner; the
|
||||
/// tile extends UP and to the RIGHT of it.
|
||||
/// - `.center`: tile centered on the name.
|
||||
private func tileRect(_ box: CGRect, _ w: Int, _ h: Int) -> CGRect {
|
||||
let W = Double(w), H = Double(h)
|
||||
let name = pixelRect(box, w, h)
|
||||
let nw = name.width * config.tileExpandX
|
||||
let nh = name.height * config.tileExpandY
|
||||
let cx = name.midX
|
||||
let rect: CGRect
|
||||
if config.nameAtBottom {
|
||||
switch config.nameAnchor {
|
||||
case .bottomCenter:
|
||||
let bottom = name.maxY + name.height * 0.3
|
||||
rect = CGRect(x: cx - nw / 2, y: bottom - nh, width: nw, height: nh)
|
||||
} else {
|
||||
rect = CGRect(x: cx - nw / 2, y: name.midY - nh / 2, width: nw, height: nh)
|
||||
rect = CGRect(x: name.midX - nw / 2, y: bottom - nh, width: nw, height: nh)
|
||||
case .bottomLeft:
|
||||
let bottom = name.maxY + name.height * 0.3
|
||||
let left = name.minX - name.height * 0.4 // small left padding ≈ the corner gutter
|
||||
rect = CGRect(x: left, y: bottom - nh, width: nw, height: nh)
|
||||
case .center:
|
||||
rect = CGRect(x: name.midX - nw / 2, y: name.midY - nh / 2, width: nw, height: nh)
|
||||
}
|
||||
return rect.intersection(CGRect(x: 0, y: 0, width: W, height: H))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user