48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
using OpenCVForUnity.CoreModule;
|
||
using OpenCVForUnity.ImgprocModule;
|
||
using OpenCVForUnity.UnityUtils;
|
||
using OpenCVForUnity.UnityUtils.Helper;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using Yoga;
|
||
|
||
public abstract class Estimator
|
||
{
|
||
//初始化
|
||
public void Init()
|
||
{
|
||
|
||
|
||
InitModel();
|
||
}
|
||
|
||
public abstract void InitModel();
|
||
|
||
public void Dispose()
|
||
{
|
||
DisposeModel();
|
||
}
|
||
public abstract void DisposeModel();
|
||
|
||
public abstract bool Esitmate(Mat bgrMat, Mat rgbaMat, out List<Point> points);
|
||
|
||
protected bool IsObjectValid(float[] box, float[] confidence, float[] classID, Mat rgbaMat)
|
||
{
|
||
if ((int)classID[0] != 0 || confidence[0] < 0.8f) //只检测人体,且置信度大于80%
|
||
return false;
|
||
|
||
//是否满足主驾/副驾的位置条件
|
||
float width = rgbaMat.width();
|
||
//获取矩形的中点
|
||
float centerX = (box[0] + box[2]) / 2;
|
||
//左边副驾驶,右边主驾驶
|
||
|
||
return true;
|
||
}
|
||
|
||
public abstract void DebugPrint(Mat img, bool isRGB = false);
|
||
|
||
public virtual void Check(ref Mat img) { }
|
||
}
|