2023-11-15 08:10:56 +00:00
|
|
|
|
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()
|
|
|
|
|
{
|
2023-11-17 06:44:27 +00:00
|
|
|
|
|
2023-11-15 08:10:56 +00:00
|
|
|
|
|
|
|
|
|
InitModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract void InitModel();
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
DisposeModel();
|
|
|
|
|
}
|
|
|
|
|
public abstract void DisposeModel();
|
|
|
|
|
|
2023-11-17 06:44:27 +00:00
|
|
|
|
public abstract bool Esitmate(Mat bgrMat, Mat rgbaMat, out List<Point> points);
|
2023-11-15 08:10:56 +00:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-17 06:44:27 +00:00
|
|
|
|
public abstract void DebugPrint(Mat img, bool isRGB = false);
|
2023-11-15 08:10:56 +00:00
|
|
|
|
|
|
|
|
|
public virtual void Check(ref Mat img) { }
|
|
|
|
|
}
|