mirror of
https://github.com/m5stack/StackFlow.git
synced 2026-05-20 11:32:11 -07:00
[update] add llm_skel(Temporary version)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import os
|
||||
|
||||
Import('env')
|
||||
with open(env['PROJECT_TOOL_S']) as f:
|
||||
exec(f.read())
|
||||
|
||||
SRCS = append_srcs_dir(ADir('src'))
|
||||
INCLUDE = [ADir('include'), ADir('.')]
|
||||
PRIVATE_INCLUDE = []
|
||||
REQUIREMENTS = ['pthread', 'utilities', 'ax_msp', 'eventpp', 'StackFlow', 'ax-samples']
|
||||
|
||||
STATIC_LIB = []
|
||||
DYNAMIC_LIB = []
|
||||
DEFINITIONS = []
|
||||
DEFINITIONS_PRIVATE = []
|
||||
LDFLAGS = []
|
||||
LINK_SEARCH_PATH = []
|
||||
STATIC_FILES = []
|
||||
|
||||
DEFINITIONS += ['-std=c++17']
|
||||
LDFLAGS+=['-Wl,-rpath=/opt/m5stack/lib', '-Wl,-rpath=/usr/local/m5stack/lib', '-Wl,-rpath=/usr/local/m5stack/lib/gcc-10.3', '-Wl,-rpath=/opt/lib', '-Wl,-rpath=/opt/usr/lib', '-Wl,-rpath=./']
|
||||
LINK_SEARCH_PATH += [ADir('../static_lib')]
|
||||
REQUIREMENTS += ['ax_engine', 'ax_interpreter', 'ax_sys']
|
||||
REQUIREMENTS += ['ax_skel', 'ax_engine', 'ax_venc', 'ax_vdec', 'ax_ivps', 'ax_proton']
|
||||
|
||||
INCLUDE += [ADir('../include'), ADir('src/runner'), ADir('../include/opencv4')]
|
||||
|
||||
static_file = Glob('../static_lib/module-llm/libabsl_*')
|
||||
static_file = Glob('../static_lib/libopencv-4.6-aarch64-none/lib/lib*')
|
||||
STATIC_LIB += static_file * 2
|
||||
|
||||
|
||||
|
||||
env['COMPONENTS'].append({'target':'llm_skel',
|
||||
'SRCS':SRCS,
|
||||
'INCLUDE':INCLUDE,
|
||||
'PRIVATE_INCLUDE':PRIVATE_INCLUDE,
|
||||
'REQUIREMENTS':REQUIREMENTS,
|
||||
'STATIC_LIB':STATIC_LIB,
|
||||
'DYNAMIC_LIB':DYNAMIC_LIB,
|
||||
'DEFINITIONS':DEFINITIONS,
|
||||
'DEFINITIONS_PRIVATE':DEFINITIONS_PRIVATE,
|
||||
'LDFLAGS':LDFLAGS,
|
||||
'LINK_SEARCH_PATH':LINK_SEARCH_PATH,
|
||||
'STATIC_FILES':STATIC_FILES,
|
||||
'REGISTER':'project'
|
||||
})
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,269 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#include "YuvHandler.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
///
|
||||
typedef struct _YUV_COLOR_S {
|
||||
AX_U8 Y;
|
||||
AX_U8 U;
|
||||
AX_U8 V;
|
||||
} YUV_COLOR_S;
|
||||
|
||||
YUV_COLOR_S g_YuvColors[YUV_COLOR_MAX] = {
|
||||
{0x00, 0x00, 0x00}, // green
|
||||
{0x00, 0x00, 0xff}, // red
|
||||
{0x00, 0xff, 0x00}, // blue
|
||||
{0x00, 0xff, 0xff}, // purple
|
||||
{0xff, 0x00, 0x00}, // dark green
|
||||
{0xff, 0x00, 0xff}, // yellow
|
||||
{0xff, 0xff, 0x00}, // light blue
|
||||
{0xff, 0xff, 0xff}, // light purple
|
||||
{0x00, 0x80, 0x80}, // dark black
|
||||
{0x80, 0x80, 0x80}, // gray
|
||||
{0xff, 0x80, 0x80} // white
|
||||
};
|
||||
|
||||
static AX_VOID DrawPointInternal(YUV_IMAGE_T *pstImage, AX_U8 *y, AX_U8 *u, AX_U8 *v, AX_U16 x0, AX_U16 y0,
|
||||
YUV_COLOR eColor) {
|
||||
if (!pstImage) {
|
||||
return;
|
||||
}
|
||||
|
||||
AX_S16 m_stride = pstImage->stride;
|
||||
AX_S16 m_eType = pstImage->eType;
|
||||
|
||||
AX_U32 y_offset = 0;
|
||||
AX_U32 u_offset = 0;
|
||||
AX_U32 v_offset = 0;
|
||||
switch (m_eType) {
|
||||
case AX_FORMAT_YUV420_PLANAR: // YUV420 I420
|
||||
/* YYYY...UUUU...VVVV */
|
||||
y_offset = (AX_U32)(y0 * m_stride + x0);
|
||||
u_offset = (AX_U32)((y0 / 2) * (m_stride / 2) + x0 / 2);
|
||||
v_offset = u_offset;
|
||||
|
||||
y[y_offset] = g_YuvColors[eColor].Y;
|
||||
u[u_offset] = g_YuvColors[eColor].U;
|
||||
v[v_offset] = g_YuvColors[eColor].V;
|
||||
break;
|
||||
|
||||
case AX_FORMAT_YUV420_SEMIPLANAR: // YUV420SP NV12
|
||||
/* YYYY...UVUV */
|
||||
y_offset = (AX_U32)(y0 * m_stride + x0);
|
||||
u_offset = (AX_U32)((y0 / 2) * m_stride + x0 / 2 * 2);
|
||||
v_offset = u_offset + 1;
|
||||
|
||||
if (g_YuvColors[eColor].Y == 0xFF) {
|
||||
y[y_offset] = g_YuvColors[eColor].Y;
|
||||
} else {
|
||||
u[u_offset] = g_YuvColors[eColor].U;
|
||||
v[v_offset] = g_YuvColors[eColor].V;
|
||||
}
|
||||
break;
|
||||
|
||||
case AX_FORMAT_YUV420_SEMIPLANAR_VU: // YUV420SP NV21
|
||||
/* YYYY...VUVU */
|
||||
y_offset = (AX_U32)(y0 * m_stride + x0);
|
||||
v_offset = (AX_U32)((y0 / 2) * m_stride + x0 / 2 * 2);
|
||||
u_offset = v_offset + 1;
|
||||
|
||||
y[y_offset] = g_YuvColors[eColor].Y;
|
||||
u[u_offset] = g_YuvColors[eColor].U;
|
||||
v[v_offset] = g_YuvColors[eColor].V;
|
||||
break;
|
||||
|
||||
case AX_FORMAT_YUV422_INTERLEAVED_UYVY:
|
||||
/* UYVYUYVY */
|
||||
u_offset = (AX_U32)(y0 * m_stride * 2 + x0 / 2 * 4);
|
||||
v_offset = u_offset + 2;
|
||||
y_offset = u_offset + 1;
|
||||
y[y_offset] = g_YuvColors[eColor].Y;
|
||||
y[y_offset + 2] = g_YuvColors[eColor].Y;
|
||||
y[u_offset] = g_YuvColors[eColor].U;
|
||||
y[v_offset] = g_YuvColors[eColor].V;
|
||||
break;
|
||||
|
||||
case AX_FORMAT_YUV422_INTERLEAVED_YUYV:
|
||||
/* YUYVYUYV */
|
||||
y_offset = (AX_U32)(y0 * m_stride * 2 + x0 / 2 * 4);
|
||||
u_offset = y_offset + 1;
|
||||
v_offset = u_offset + 2;
|
||||
|
||||
y[y_offset] = g_YuvColors[eColor].Y;
|
||||
y[y_offset + 2] = g_YuvColors[eColor].Y;
|
||||
y[u_offset] = g_YuvColors[eColor].U;
|
||||
y[v_offset] = g_YuvColors[eColor].V;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AX_VOID DrawPoint(YUV_IMAGE_T *pstImage, AX_S16 x, AX_S16 y, AX_U8 nScale /* = 1*/, AX_S16 x_offset /* = 0*/,
|
||||
AX_S16 y_offset /* = 0*/, YUV_COLOR eColor /* = YUV_GREEN*/) {
|
||||
if (!pstImage) {
|
||||
return;
|
||||
}
|
||||
|
||||
AX_U8 *m_pImage = pstImage->pImage;
|
||||
AX_S16 m_nWidth = pstImage->nWidth;
|
||||
AX_S16 m_nHeight = pstImage->nHeight;
|
||||
AX_S16 m_stride = pstImage->stride;
|
||||
AX_S16 m_eType = pstImage->eType;
|
||||
|
||||
AX_U8 *pY = NULL;
|
||||
AX_U8 *pU = NULL;
|
||||
AX_U8 *pV = NULL;
|
||||
switch (m_eType) {
|
||||
case AX_FORMAT_YUV420_PLANAR:
|
||||
pY = m_pImage;
|
||||
pU = m_pImage + m_stride * m_nHeight;
|
||||
pV = pU + m_stride * m_nHeight / 4;
|
||||
break;
|
||||
case AX_FORMAT_YUV420_SEMIPLANAR:
|
||||
case AX_FORMAT_YUV420_SEMIPLANAR_VU:
|
||||
pY = m_pImage;
|
||||
pU = m_pImage + m_stride * m_nHeight;
|
||||
pV = pU;
|
||||
break;
|
||||
case AX_FORMAT_YUV422_INTERLEAVED_UYVY:
|
||||
case AX_FORMAT_YUV422_INTERLEAVED_YUYV:
|
||||
pY = m_pImage;
|
||||
pU = pY;
|
||||
pV = pY;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
AX_S16 nXStart = 0;
|
||||
AX_S16 nYStart = 0;
|
||||
for (AX_U32 hScale = 0; hScale < nScale; hScale++) {
|
||||
for (AX_U32 wScale = 0; wScale < nScale; wScale++) {
|
||||
nXStart = x * nScale + hScale - x_offset;
|
||||
nYStart = y * nScale + wScale - y_offset;
|
||||
if (nXStart < 0 || nXStart > m_nWidth) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (nYStart < 0 || nYStart > m_nHeight) {
|
||||
break;
|
||||
}
|
||||
|
||||
DrawPointInternal(pstImage, pY, pU, pV, nXStart, nYStart, eColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AX_VOID DrawLine(YUV_IMAGE_T *pstImage, AX_S16 x0, AX_S16 y0, AX_S16 x1, AX_S16 y1, YUV_COLOR eColor /* = YUV_GREEN*/,
|
||||
AX_U8 nScale /* = 1*/)
|
||||
|
||||
{
|
||||
if (!pstImage) {
|
||||
return;
|
||||
}
|
||||
|
||||
AX_U8 *m_pImage = pstImage->pImage;
|
||||
AX_S16 m_nWidth = pstImage->nWidth;
|
||||
AX_S16 m_nHeight = pstImage->nHeight;
|
||||
AX_S16 m_stride = pstImage->stride;
|
||||
AX_S16 m_eType = pstImage->eType;
|
||||
|
||||
x0 = (x0 < 0) ? 0 : x0;
|
||||
y0 = (y0 < 0) ? 0 : y0;
|
||||
x1 = (x1 < 0) ? 0 : x1;
|
||||
y1 = (y1 < 0) ? 0 : y1;
|
||||
|
||||
x0 = (x0 >= m_nWidth) ? m_nWidth - 1 : x0;
|
||||
y0 = (y0 >= m_nHeight) ? m_nHeight - 1 : y0;
|
||||
x1 = (x1 >= m_nWidth) ? m_nWidth - 1 : x1;
|
||||
y1 = (y1 >= m_nHeight) ? m_nHeight - 1 : y1;
|
||||
|
||||
AX_U16 dx = (x0 > x1) ? (x0 - x1) : (x1 - x0);
|
||||
AX_U16 dy = (y0 > y1) ? (y0 - y1) : (y1 - y0);
|
||||
|
||||
AX_S16 xstep = (x0 < x1) ? 1 : -1;
|
||||
AX_S16 ystep = (y0 < y1) ? 1 : -1;
|
||||
AX_S16 nstep = 0, eps = 0;
|
||||
|
||||
AX_U8 *pY = NULL;
|
||||
AX_U8 *pU = NULL;
|
||||
AX_U8 *pV = NULL;
|
||||
switch (m_eType) {
|
||||
case AX_FORMAT_YUV420_PLANAR:
|
||||
pY = m_pImage;
|
||||
pU = m_pImage + m_stride * m_nHeight;
|
||||
pV = pU + m_stride * m_nHeight / 4;
|
||||
break;
|
||||
case AX_FORMAT_YUV420_SEMIPLANAR:
|
||||
case AX_FORMAT_YUV420_SEMIPLANAR_VU:
|
||||
pY = m_pImage;
|
||||
pU = m_pImage + m_stride * m_nHeight;
|
||||
pV = pU;
|
||||
break;
|
||||
case AX_FORMAT_YUV422_INTERLEAVED_UYVY:
|
||||
case AX_FORMAT_YUV422_INTERLEAVED_YUYV:
|
||||
pY = m_pImage;
|
||||
pU = pY;
|
||||
pV = pY;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
AX_U16 x = x0;
|
||||
AX_U16 y = y0;
|
||||
if (dx > dy) {
|
||||
while (nstep <= dx) {
|
||||
if (nScale == 1) {
|
||||
DrawPointInternal(pstImage, pY, pU, pV, x, y, eColor);
|
||||
} else {
|
||||
DrawPoint(pstImage, x, y, nScale, x * (nScale - 1), y * (nScale - 1), eColor);
|
||||
}
|
||||
eps += dy;
|
||||
if ((eps << 1) >= dx) {
|
||||
y += ystep;
|
||||
eps -= dx;
|
||||
}
|
||||
x += xstep;
|
||||
nstep++;
|
||||
}
|
||||
} else {
|
||||
while (nstep <= dy) {
|
||||
if (nScale == 1) {
|
||||
DrawPointInternal(pstImage, pY, pU, pV, x, y, eColor);
|
||||
} else {
|
||||
DrawPoint(pstImage, x, y, nScale, x * (nScale - 1), y * (nScale - 1), eColor);
|
||||
}
|
||||
eps += dx;
|
||||
if ((eps << 1) >= dy) {
|
||||
x += xstep;
|
||||
eps -= dy;
|
||||
}
|
||||
y += ystep;
|
||||
nstep++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AX_VOID DrawRect(YUV_IMAGE_T *pstImage, AX_S16 x0, AX_S16 y0, AX_U16 w, AX_U16 h, YUV_COLOR eColor /* = YUV_GREEN*/) {
|
||||
if (w > 0 && h > 0) {
|
||||
DrawLine(pstImage, x0, y0, x0 + w, y0, eColor, 1);
|
||||
DrawLine(pstImage, x0, y0, x0, y0 + h, eColor, 1);
|
||||
DrawLine(pstImage, x0 + w, y0, x0 + w, y0 + h, eColor, 1);
|
||||
DrawLine(pstImage, x0, y0 + h, x0 + w, y0 + h, eColor, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifndef _YUV_HANDLER_H_
|
||||
#define _YUV_HANDLER_H_
|
||||
|
||||
#include "ax_global_type.h"
|
||||
#include "ax_sys_api.h"
|
||||
|
||||
typedef enum _YUV_COLOR {
|
||||
YUV_GREEN = 0,
|
||||
YUV_RED,
|
||||
YUV_BLUE,
|
||||
YUV_PURPLE,
|
||||
YUV_DARK_GREEN,
|
||||
YUV_YELLOW,
|
||||
YUV_LIGHT_BLUE,
|
||||
YUV_LIGHT_PURPLE,
|
||||
YUV_DARK_BLACK,
|
||||
YUV_GRAY,
|
||||
YUV_WHITE,
|
||||
YUV_COLOR_MAX,
|
||||
} YUV_COLOR;
|
||||
|
||||
typedef struct _YUV_IMAGE_T {
|
||||
AX_U8 *pImage;
|
||||
AX_U16 nWidth;
|
||||
AX_U16 nHeight;
|
||||
AX_S16 stride;
|
||||
AX_U32 nSize;
|
||||
AX_IMG_FORMAT_E eType;
|
||||
} YUV_IMAGE_T;
|
||||
|
||||
AX_VOID DrawLine(YUV_IMAGE_T *pstImage, AX_S16 x0, AX_S16 y0, AX_S16 x1, AX_S16 y1, YUV_COLOR eColor, AX_U8 nScale);
|
||||
AX_VOID DrawRect(YUV_IMAGE_T *pstImage, AX_S16 x0, AX_S16 y0, AX_U16 w, AX_U16 h, YUV_COLOR eColor);
|
||||
AX_VOID DrawPoint(YUV_IMAGE_T *pstImage, AX_S16 x, AX_S16 y, AX_U8 nScale, AX_S16 x_offset, AX_S16 y_offset,
|
||||
YUV_COLOR eColor);
|
||||
|
||||
#endif /* _YUV_HANDLER_H_ */
|
||||
@@ -0,0 +1,224 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#include "attrParser.h"
|
||||
#include "picojson.h"
|
||||
|
||||
#define PICO_OBJECT get<picojson::object>()
|
||||
#define PICO_OBJECT_SIZE PICO_OBJECT.size()
|
||||
#define PICO_ARRAY get<picojson::array>()
|
||||
#define PICO_ARRAY_SIZE PICO_ARRAY.size()
|
||||
#define PICO_VALUE get<double>()
|
||||
#define PICO_BOOL get<bool>()
|
||||
#define PICO_STRING get<std::string>()
|
||||
#define PICO_ROOT obj.PICO_OBJECT
|
||||
|
||||
typedef struct _AI_Face_Attr_t {
|
||||
AX_F32 fYaw;
|
||||
AX_F32 fPitch;
|
||||
AX_F32 fRoll;
|
||||
AX_F32 fMask;
|
||||
AX_U8 age;
|
||||
AX_U8 gender;
|
||||
AX_F32 fScore;
|
||||
} AI_Face_Attr_t;
|
||||
|
||||
typedef struct _AI_Plate_Attr_t {
|
||||
AX_BOOL bExist;
|
||||
AX_BOOL bValid;
|
||||
/*
|
||||
string:
|
||||
blue
|
||||
yellow
|
||||
black
|
||||
white
|
||||
green
|
||||
small_new_energy
|
||||
large_new_energy
|
||||
absence
|
||||
unknown
|
||||
*/
|
||||
std::string strPlateColor;
|
||||
/*
|
||||
string:
|
||||
one_row
|
||||
two_rows
|
||||
unknown
|
||||
*/
|
||||
std::string strPlateType;
|
||||
/* string: UTF8*/
|
||||
std::string strPlateCode;
|
||||
|
||||
_AI_Plate_Attr_t() {
|
||||
bExist = AX_FALSE;
|
||||
bValid = AX_FALSE;
|
||||
strPlateColor = "";
|
||||
strPlateType = "";
|
||||
strPlateCode = "";
|
||||
}
|
||||
} AI_Plate_Attr_t;
|
||||
|
||||
static AX_VOID FaceAttrResult(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, ATTRINFO_T *pAttrInfo) {
|
||||
picojson::value obj;
|
||||
AI_Face_Attr_t face_attr;
|
||||
|
||||
pAttrInfo->eType = ATTR_TYPE_FACE;
|
||||
|
||||
for (size_t i = 0; i < pstObjectItems->nMetaInfoSize; i++) {
|
||||
if (!strcmp(pstObjectItems->pstMetaInfo[i].pstrType, "face_attr")) {
|
||||
std::string value = pstObjectItems->pstMetaInfo[i].pstrValue;
|
||||
std::string strParseRet = picojson::parse(obj, value);
|
||||
if (!strParseRet.empty() || !obj.is<picojson::object>()) {
|
||||
break;
|
||||
}
|
||||
// age
|
||||
face_attr.age = PICO_ROOT["age"].PICO_VALUE;
|
||||
printf("ageis %d\n",face_attr.age);
|
||||
// gender
|
||||
face_attr.gender = PICO_ROOT["gender"].PICO_VALUE;
|
||||
// yaw
|
||||
face_attr.fYaw = PICO_ROOT["yaw"].PICO_VALUE;
|
||||
// pitch
|
||||
face_attr.fPitch = PICO_ROOT["pitch"].PICO_VALUE;
|
||||
// roll
|
||||
face_attr.fRoll = PICO_ROOT["roll"].PICO_VALUE;
|
||||
// mask
|
||||
face_attr.fMask = PICO_ROOT["mask"].PICO_VALUE;
|
||||
// score
|
||||
face_attr.fScore = PICO_ROOT["score"].PICO_VALUE;
|
||||
printf("score is %f\n",face_attr.fScore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static AX_VOID PlateAttrResult(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, ATTRINFO_T *pAttrInfo) {
|
||||
picojson::value obj;
|
||||
AI_Plate_Attr_t plat_attr;
|
||||
|
||||
pAttrInfo->eType = ATTR_TYPE_PLATE;
|
||||
|
||||
plat_attr.bExist = AX_FALSE;
|
||||
plat_attr.bValid = AX_FALSE;
|
||||
plat_attr.strPlateColor = "";
|
||||
plat_attr.strPlateType = "";
|
||||
plat_attr.strPlateCode = "";
|
||||
|
||||
for (size_t i = 0; i < pstObjectItems->nMetaInfoSize; i++) {
|
||||
if (!strcmp(pstObjectItems->pstMetaInfo[i].pstrType, "plate_attr")) {
|
||||
std::string value = pstObjectItems->pstMetaInfo[i].pstrValue;
|
||||
std::string strParseRet = picojson::parse(obj, value);
|
||||
if (!strParseRet.empty() || !obj.is<picojson::object>()) {
|
||||
break;
|
||||
}
|
||||
|
||||
plat_attr.bExist = AX_TRUE;
|
||||
// color
|
||||
plat_attr.strPlateColor = "unknown";
|
||||
if (PICO_ROOT.end() != PICO_ROOT.find("color")) {
|
||||
plat_attr.strPlateColor = PICO_ROOT["color"].PICO_OBJECT["name"].PICO_STRING;
|
||||
}
|
||||
|
||||
// style
|
||||
plat_attr.strPlateType = "unknown";
|
||||
if (PICO_ROOT.end() != PICO_ROOT.find("style")) {
|
||||
plat_attr.strPlateType = PICO_ROOT["style"].PICO_OBJECT["name"].PICO_STRING;
|
||||
}
|
||||
|
||||
// code
|
||||
plat_attr.strPlateCode = PICO_ROOT["code_result"].PICO_STRING;
|
||||
|
||||
if (PICO_ROOT["code_killed"].PICO_BOOL) {
|
||||
plat_attr.bValid = AX_FALSE;
|
||||
} else {
|
||||
plat_attr.bValid = AX_TRUE;
|
||||
}
|
||||
|
||||
pAttrInfo->bExist = AX_TRUE;
|
||||
|
||||
strncpy(pAttrInfo->tPlateInfo.szColor, (const AX_CHAR *)plat_attr.strPlateColor.c_str(), sizeof(pAttrInfo->tPlateInfo.szColor) - 1);
|
||||
|
||||
pAttrInfo->tPlateInfo.bValid = plat_attr.bValid;
|
||||
strncpy(pAttrInfo->tPlateInfo.szNum, (const AX_CHAR *)plat_attr.strPlateCode.c_str(), sizeof(pAttrInfo->tPlateInfo.szNum) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static AX_VOID VehicleAttrResult(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, ATTRINFO_T *pAttrInfo) {
|
||||
picojson::value obj;
|
||||
AI_Plate_Attr_t plat_attr;
|
||||
|
||||
pAttrInfo->eType = ATTR_TYPE_VEHICLE;
|
||||
|
||||
plat_attr.bExist = AX_FALSE;
|
||||
plat_attr.bValid = AX_FALSE;
|
||||
plat_attr.strPlateColor = "";
|
||||
plat_attr.strPlateType = "";
|
||||
plat_attr.strPlateCode = "";
|
||||
|
||||
for (size_t i = 0; i < pstObjectItems->nMetaInfoSize; i++) {
|
||||
if (!strcmp(pstObjectItems->pstMetaInfo[i].pstrType, "plate_attr")) {
|
||||
std::string value = pstObjectItems->pstMetaInfo[i].pstrValue;
|
||||
std::string strParseRet = picojson::parse(obj, value);
|
||||
if (!strParseRet.empty() || !obj.is<picojson::object>()) {
|
||||
break;
|
||||
}
|
||||
|
||||
plat_attr.bExist = AX_TRUE;
|
||||
// color
|
||||
plat_attr.strPlateColor = "unknown";
|
||||
if (PICO_ROOT.end() != PICO_ROOT.find("color")) {
|
||||
plat_attr.strPlateColor = PICO_ROOT["color"].PICO_OBJECT["name"].PICO_STRING;
|
||||
}
|
||||
|
||||
// style
|
||||
plat_attr.strPlateType = "unknown";
|
||||
if (PICO_ROOT.end() != PICO_ROOT.find("style")) {
|
||||
plat_attr.strPlateType = PICO_ROOT["style"].PICO_OBJECT["name"].PICO_STRING;
|
||||
}
|
||||
|
||||
// code
|
||||
plat_attr.strPlateCode = PICO_ROOT["code_result"].PICO_STRING;
|
||||
|
||||
if (PICO_ROOT["code_killed"].PICO_BOOL) {
|
||||
plat_attr.bValid = AX_FALSE;
|
||||
} else {
|
||||
plat_attr.bValid = AX_TRUE;
|
||||
}
|
||||
|
||||
pAttrInfo->bExist = AX_TRUE;
|
||||
|
||||
strncpy(pAttrInfo->tPlateInfo.szColor, (const AX_CHAR *)plat_attr.strPlateColor.c_str(), sizeof(pAttrInfo->tPlateInfo.szColor) - 1);
|
||||
|
||||
pAttrInfo->tPlateInfo.bValid = plat_attr.bValid;
|
||||
strncpy(pAttrInfo->tPlateInfo.szNum, (const AX_CHAR *)plat_attr.strPlateCode.c_str(), sizeof(pAttrInfo->tPlateInfo.szNum) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AX_VOID AttrParser(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, ATTRINFO_T *pAttrInfo) {
|
||||
if (!pstObjectItems || !pAttrInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
pAttrInfo->bExist = AX_FALSE;
|
||||
pAttrInfo->eType = ATTR_TYPE_BUTT;
|
||||
|
||||
std::string strObjectCategory = pstObjectItems->pstrObjectCategory;
|
||||
|
||||
if (strObjectCategory == "face") {
|
||||
FaceAttrResult(pstObjectItems, pAttrInfo);
|
||||
}
|
||||
else if (strObjectCategory == "plate") {
|
||||
PlateAttrResult(pstObjectItems, pAttrInfo);
|
||||
}
|
||||
else if (strObjectCategory == "vehicle") {
|
||||
VehicleAttrResult(pstObjectItems, pAttrInfo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifndef _ATTR_PARSER_H_
|
||||
#define _ATTR_PARSER_H_
|
||||
#include "ax_global_type.h"
|
||||
#include "ax_sys_api.h"
|
||||
#include "ax_skel_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum _ATTR_TYPE_E {
|
||||
ATTR_TYPE_BODY = 0,
|
||||
ATTR_TYPE_VEHICLE,
|
||||
ATTR_TYPE_CYCLE,
|
||||
ATTR_TYPE_FACE,
|
||||
ATTR_TYPE_PLATE,
|
||||
ATTR_TYPE_BUTT
|
||||
} ATTR_TYPE_E;
|
||||
|
||||
typedef struct _FACEINFO_T {
|
||||
AX_U8 nGender; /* 0-female, 1-male */
|
||||
AX_U8 nAge;
|
||||
AX_CHAR szMask[32];
|
||||
AX_CHAR szGender[32];
|
||||
} FACEINFO_T;
|
||||
|
||||
typedef struct _PLATEINFO_T {
|
||||
AX_BOOL bValid;
|
||||
AX_CHAR szNum[16];
|
||||
AX_CHAR szColor[32];
|
||||
} PLATEINFO_T;
|
||||
|
||||
typedef struct _ATTRINFO_T {
|
||||
ATTR_TYPE_E eType; /* ATTR_TYPE_E */
|
||||
AX_BOOL bExist;
|
||||
|
||||
union
|
||||
{
|
||||
FACEINFO_T tFaceInfo;
|
||||
PLATEINFO_T tPlateInfo;
|
||||
};
|
||||
} ATTRINFO_T;
|
||||
|
||||
extern AX_VOID AttrParser(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, ATTRINFO_T *pAttrInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+2233
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,72 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include "frameMgr.h"
|
||||
#include <iostream>
|
||||
|
||||
AX_BOOL g_bSkel_frame_mgr_inited = AX_FALSE;
|
||||
AX_POOL g_skel_frame_poolId = AX_INVALID_POOLID;
|
||||
|
||||
AX_VOID FrameMgrCreate(AX_U32 nFrameSize, AX_U32 nDepth) {
|
||||
AX_POOL_CONFIG_T stPoolConfig;
|
||||
|
||||
memset(&stPoolConfig, 0, sizeof(AX_POOL_CONFIG_T));
|
||||
stPoolConfig.MetaSize = 4096;
|
||||
stPoolConfig.BlkCnt = nDepth;
|
||||
stPoolConfig.BlkSize = nFrameSize;
|
||||
stPoolConfig.CacheMode = AX_POOL_CACHE_MODE_NONCACHE;
|
||||
memset(stPoolConfig.PartitionName, 0, sizeof(stPoolConfig.PartitionName));
|
||||
strcpy((AX_CHAR *)stPoolConfig.PartitionName, "anonymous");
|
||||
|
||||
g_skel_frame_poolId = AX_POOL_CreatePool(&stPoolConfig);
|
||||
g_bSkel_frame_mgr_inited = AX_TRUE;
|
||||
}
|
||||
|
||||
AX_BOOL FrameMgrGet(AX_U64 *YUVDataPhy, AX_VOID **YUVDataVir, AX_U32 nFrameSize, AX_U64 nFrameId, AX_BLK *nBlkId) {
|
||||
if (!g_bSkel_frame_mgr_inited
|
||||
|| g_skel_frame_poolId == AX_INVALID_POOLID) {
|
||||
return AX_FALSE;
|
||||
}
|
||||
|
||||
AX_BLK blkId = AX_POOL_GetBlock(g_skel_frame_poolId, nFrameSize, NULL);
|
||||
|
||||
if (blkId != AX_INVALID_BLOCKID) {
|
||||
*YUVDataPhy = AX_POOL_Handle2PhysAddr(blkId);
|
||||
*YUVDataVir = AX_POOL_GetBlockVirAddr(blkId);
|
||||
*nBlkId = blkId;
|
||||
|
||||
return AX_TRUE;
|
||||
}
|
||||
|
||||
return AX_FALSE;
|
||||
}
|
||||
|
||||
AX_VOID FrameMgrRelease(AX_BLK blkId) {
|
||||
if (blkId != AX_INVALID_BLOCKID) {
|
||||
blkId = AX_POOL_ReleaseBlock(blkId);
|
||||
}
|
||||
}
|
||||
|
||||
AX_VOID FrameMgrDestroy(AX_VOID) {
|
||||
if (!g_bSkel_frame_mgr_inited
|
||||
|| g_skel_frame_poolId == AX_INVALID_POOLID) {
|
||||
return;
|
||||
}
|
||||
|
||||
AX_POOL_DestroyPool(g_skel_frame_poolId);
|
||||
|
||||
g_skel_frame_poolId = AX_INVALID_POOLID;
|
||||
g_bSkel_frame_mgr_inited = AX_FALSE;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifndef _FRAME_MGR_H_
|
||||
#define _FRAME_MGR_H_
|
||||
#include "ax_global_type.h"
|
||||
#include "ax_sys_api.h"
|
||||
#include "ax_skel_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SKEL_FRAME_BUF_DEFAULT_DEPTH 2
|
||||
|
||||
AX_VOID FrameMgrCreate(AX_U32 nFrameSize, AX_U32 nDepth);
|
||||
AX_BOOL FrameMgrGet(AX_U64 *YUVDataPhy, AX_VOID **YUVDataVir, AX_U32 nFrameSize, AX_U64 nFrameId, AX_BLK *nBlkId);
|
||||
AX_VOID FrameMgrRelease(AX_BLK nBlkId);
|
||||
AX_VOID FrameMgrDestroy(AX_VOID);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifndef _SAMPLE_SKEL_LOG_H_
|
||||
#define _SAMPLE_SKEL_LOG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum {
|
||||
SKEL_LOG_MIN = -1,
|
||||
SKEL_LOG_EMERGENCY = 0,
|
||||
SKEL_LOG_ALERT = 1,
|
||||
SKEL_LOG_CRITICAL = 2,
|
||||
SKEL_LOG_ERROR = 3,
|
||||
SKEL_LOG_WARN = 4,
|
||||
SKEL_LOG_NOTICE = 5,
|
||||
SKEL_LOG_INFO = 6,
|
||||
SKEL_LOG_DEBUG = 7,
|
||||
SKEL_LOG_MAX
|
||||
} SKEL_LOG_LEVEL_E;
|
||||
|
||||
static SKEL_LOG_LEVEL_E log_level = SKEL_LOG_NOTICE;
|
||||
|
||||
#if 1
|
||||
#define MACRO_BLACK "\033[1;30;30m"
|
||||
#define MACRO_RED "\033[1;30;31m"
|
||||
#define MACRO_GREEN "\033[1;30;32m"
|
||||
#define MACRO_YELLOW "\033[1;30;33m"
|
||||
#define MACRO_BLUE "\033[1;30;34m"
|
||||
#define MACRO_PURPLE "\033[1;30;35m"
|
||||
#define MACRO_WHITE "\033[1;30;37m"
|
||||
#define MACRO_END "\033[0m"
|
||||
#else
|
||||
#define MACRO_BLACK
|
||||
#define MACRO_RED
|
||||
#define MACRO_GREEN
|
||||
#define MACRO_YELLOW
|
||||
#define MACRO_BLUE
|
||||
#define MACRO_PURPLE
|
||||
#define MACRO_WHITE
|
||||
#define MACRO_END
|
||||
#endif
|
||||
|
||||
#define ALOGE(fmt, ...) printf(MACRO_RED "[E][%32s][%4d]: " fmt MACRO_END "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define ALOGW(fmt, ...) if (log_level >= SKEL_LOG_WARN) \
|
||||
printf(MACRO_YELLOW "[W][%32s][%4d]: " fmt MACRO_END "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define ALOGI(fmt, ...) if (log_level >= SKEL_LOG_INFO) \
|
||||
printf(MACRO_GREEN "[I][%32s][%4d]: " fmt MACRO_END "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define ALOGD(fmt, ...) if (log_level >= SKEL_LOG_DEBUG) \
|
||||
printf(MACRO_WHITE "[D][%32s][%4d]: " fmt MACRO_END "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define ALOGN(fmt, ...) if (log_level >= SKEL_LOG_NOTICE) \
|
||||
printf(MACRO_PURPLE "[N][%32s][%4d]: " fmt MACRO_END "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#endif /* _SAMPLE_SKEL_TRACE_H_ */
|
||||
@@ -0,0 +1,65 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#include <map>
|
||||
#include "statMgr.h"
|
||||
#include <string>
|
||||
|
||||
AX_VOID StatTrackMgr(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, STAT_OBJECT_NUM_T *pObjectNum) {
|
||||
if (!pstObjectItems || !pObjectNum) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string strObjectCategory = pstObjectItems->pstrObjectCategory;
|
||||
|
||||
if (pstObjectItems->eTrackState == AX_SKEL_TRACK_STATUS_NEW) {
|
||||
if (strObjectCategory == "body") {
|
||||
pObjectNum->nBodyNum ++;
|
||||
}
|
||||
else if (strObjectCategory == "vehicle") {
|
||||
pObjectNum->nVehicleNum ++;
|
||||
}
|
||||
else if (strObjectCategory == "cycle") {
|
||||
pObjectNum->nCycleNum ++;
|
||||
}
|
||||
else if (strObjectCategory == "face") {
|
||||
pObjectNum->nFaceNum ++;
|
||||
}
|
||||
else if (strObjectCategory == "plate") {
|
||||
pObjectNum->nPlateNum ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AX_VOID StatPushMgr(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, STAT_OBJECT_NUM_T *pObjectNum) {
|
||||
if (!pstObjectItems || !pObjectNum) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string strObjectCategory = pstObjectItems->pstrObjectCategory;
|
||||
|
||||
if (pstObjectItems->eTrackState == AX_SKEL_TRACK_STATUS_SELECT) {
|
||||
if (strObjectCategory == "body") {
|
||||
pObjectNum->nBodyNum ++;
|
||||
}
|
||||
else if (strObjectCategory == "vehicle") {
|
||||
pObjectNum->nVehicleNum ++;
|
||||
}
|
||||
else if (strObjectCategory == "cycle") {
|
||||
pObjectNum->nCycleNum ++;
|
||||
}
|
||||
else if (strObjectCategory == "face") {
|
||||
pObjectNum->nFaceNum ++;
|
||||
}
|
||||
else if (strObjectCategory == "plate") {
|
||||
pObjectNum->nPlateNum ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* This source file is the property of Axera Semiconductor Co., Ltd. and
|
||||
* may not be copied or distributed in any isomorphic form without the prior
|
||||
* written consent of Axera Semiconductor Co., Ltd.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifndef _STAT_MGR_H_
|
||||
#define _STAT_MGR_H_
|
||||
#include "ax_global_type.h"
|
||||
#include "ax_sys_api.h"
|
||||
#include "ax_skel_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _STAT_OBJECT_NUM_T {
|
||||
AX_U32 nBodyNum;
|
||||
AX_U32 nVehicleNum;
|
||||
AX_U32 nCycleNum;
|
||||
AX_U32 nFaceNum;
|
||||
AX_U32 nPlateNum;
|
||||
} STAT_OBJECT_NUM_T;
|
||||
|
||||
extern AX_VOID StatTrackMgr(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, STAT_OBJECT_NUM_T *pObjectNum);
|
||||
extern AX_VOID StatPushMgr(const AX_SKEL_OBJECT_ITEM_T *pstObjectItems, STAT_OBJECT_NUM_T *pObjectNum);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user