双目测距ROS发送
parent
352cc948b4
commit
8c76e97782
|
@ -0,0 +1 @@
|
||||||
|
# This file currently only serves to mark the location of a catkin workspace for tool integration
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"/opt/ros/noetic/include/**",
|
||||||
|
"/opt/ros/noetic/include",
|
||||||
|
"${workspaceFolder}/src/rknn_yolov5_demo/include",
|
||||||
|
"${workspaceFolder}/devel/include"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "gnu++14",
|
||||||
|
"intelliSenseMode": "linux-gcc-arm64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
{
|
||||||
|
"C_Cpp.errorSquiggles": "disabled",
|
||||||
|
"files.associations": {
|
||||||
|
"deque": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"csignal": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"any": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"hash_map": "cpp",
|
||||||
|
"hash_set": "cpp",
|
||||||
|
"strstream": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"bitset": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"codecvt": "cpp",
|
||||||
|
"complex": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"forward_list": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"unordered_set": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"set": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"future": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"shared_mutex": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"cfenv": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeindex": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"valarray": "cpp",
|
||||||
|
"variant": "cpp",
|
||||||
|
"bit": "cpp"
|
||||||
|
},
|
||||||
|
"remote.SSH.allowX11Forwarding": true,
|
||||||
|
|
||||||
|
"cmake.sourceDirectory": "/home/firefly/obj_dec/src/rknn_yolov5_demo"
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
catkin_make
|
|
@ -0,0 +1 @@
|
||||||
|
/home/firefly/obj_dec/src
|
|
@ -0,0 +1,2 @@
|
||||||
|
- setup-file:
|
||||||
|
local-name: /home/firefly/obj_dec/devel/setup.sh
|
|
@ -0,0 +1,304 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Software License Agreement (BSD License)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2012, Willow Garage, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above
|
||||||
|
# copyright notice, this list of conditions and the following
|
||||||
|
# disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||||
|
# contributors may be used to endorse or promote products derived
|
||||||
|
# from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
"""This file generates shell code for the setup.SHELL scripts to set environment variables."""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import copy
|
||||||
|
import errno
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
|
|
||||||
|
CATKIN_MARKER_FILE = '.catkin'
|
||||||
|
|
||||||
|
system = platform.system()
|
||||||
|
IS_DARWIN = (system == 'Darwin')
|
||||||
|
IS_WINDOWS = (system == 'Windows')
|
||||||
|
|
||||||
|
PATH_TO_ADD_SUFFIX = ['bin']
|
||||||
|
if IS_WINDOWS:
|
||||||
|
# while catkin recommends putting dll's into bin, 3rd party packages often put dll's into lib
|
||||||
|
# since Windows finds dll's via the PATH variable, prepend it with path to lib
|
||||||
|
PATH_TO_ADD_SUFFIX.extend([['lib', os.path.join('lib', 'aarch64-linux-gnu')]])
|
||||||
|
|
||||||
|
# subfolder of workspace prepended to CMAKE_PREFIX_PATH
|
||||||
|
ENV_VAR_SUBFOLDERS = {
|
||||||
|
'CMAKE_PREFIX_PATH': '',
|
||||||
|
'LD_LIBRARY_PATH' if not IS_DARWIN else 'DYLD_LIBRARY_PATH': ['lib', os.path.join('lib', 'aarch64-linux-gnu')],
|
||||||
|
'PATH': PATH_TO_ADD_SUFFIX,
|
||||||
|
'PKG_CONFIG_PATH': [os.path.join('lib', 'pkgconfig'), os.path.join('lib', 'aarch64-linux-gnu', 'pkgconfig')],
|
||||||
|
'PYTHONPATH': 'lib/python3/dist-packages',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def rollback_env_variables(environ, env_var_subfolders):
|
||||||
|
"""
|
||||||
|
Generate shell code to reset environment variables.
|
||||||
|
|
||||||
|
by unrolling modifications based on all workspaces in CMAKE_PREFIX_PATH.
|
||||||
|
This does not cover modifications performed by environment hooks.
|
||||||
|
"""
|
||||||
|
lines = []
|
||||||
|
unmodified_environ = copy.copy(environ)
|
||||||
|
for key in sorted(env_var_subfolders.keys()):
|
||||||
|
subfolders = env_var_subfolders[key]
|
||||||
|
if not isinstance(subfolders, list):
|
||||||
|
subfolders = [subfolders]
|
||||||
|
value = _rollback_env_variable(unmodified_environ, key, subfolders)
|
||||||
|
if value is not None:
|
||||||
|
environ[key] = value
|
||||||
|
lines.append(assignment(key, value))
|
||||||
|
if lines:
|
||||||
|
lines.insert(0, comment('reset environment variables by unrolling modifications based on all workspaces in CMAKE_PREFIX_PATH'))
|
||||||
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
def _rollback_env_variable(environ, name, subfolders):
|
||||||
|
"""
|
||||||
|
For each catkin workspace in CMAKE_PREFIX_PATH remove the first entry from env[NAME] matching workspace + subfolder.
|
||||||
|
|
||||||
|
:param subfolders: list of str '' or subfoldername that may start with '/'
|
||||||
|
:returns: the updated value of the environment variable.
|
||||||
|
"""
|
||||||
|
value = environ[name] if name in environ else ''
|
||||||
|
env_paths = [path for path in value.split(os.pathsep) if path]
|
||||||
|
value_modified = False
|
||||||
|
for subfolder in subfolders:
|
||||||
|
if subfolder:
|
||||||
|
if subfolder.startswith(os.path.sep) or (os.path.altsep and subfolder.startswith(os.path.altsep)):
|
||||||
|
subfolder = subfolder[1:]
|
||||||
|
if subfolder.endswith(os.path.sep) or (os.path.altsep and subfolder.endswith(os.path.altsep)):
|
||||||
|
subfolder = subfolder[:-1]
|
||||||
|
for ws_path in _get_workspaces(environ, include_fuerte=True, include_non_existing=True):
|
||||||
|
path_to_find = os.path.join(ws_path, subfolder) if subfolder else ws_path
|
||||||
|
path_to_remove = None
|
||||||
|
for env_path in env_paths:
|
||||||
|
env_path_clean = env_path[:-1] if env_path and env_path[-1] in [os.path.sep, os.path.altsep] else env_path
|
||||||
|
if env_path_clean == path_to_find:
|
||||||
|
path_to_remove = env_path
|
||||||
|
break
|
||||||
|
if path_to_remove:
|
||||||
|
env_paths.remove(path_to_remove)
|
||||||
|
value_modified = True
|
||||||
|
new_value = os.pathsep.join(env_paths)
|
||||||
|
return new_value if value_modified else None
|
||||||
|
|
||||||
|
|
||||||
|
def _get_workspaces(environ, include_fuerte=False, include_non_existing=False):
|
||||||
|
"""
|
||||||
|
Based on CMAKE_PREFIX_PATH return all catkin workspaces.
|
||||||
|
|
||||||
|
:param include_fuerte: The flag if paths starting with '/opt/ros/fuerte' should be considered workspaces, ``bool``
|
||||||
|
"""
|
||||||
|
# get all cmake prefix paths
|
||||||
|
env_name = 'CMAKE_PREFIX_PATH'
|
||||||
|
value = environ[env_name] if env_name in environ else ''
|
||||||
|
paths = [path for path in value.split(os.pathsep) if path]
|
||||||
|
# remove non-workspace paths
|
||||||
|
workspaces = [path for path in paths if os.path.isfile(os.path.join(path, CATKIN_MARKER_FILE)) or (include_fuerte and path.startswith('/opt/ros/fuerte')) or (include_non_existing and not os.path.exists(path))]
|
||||||
|
return workspaces
|
||||||
|
|
||||||
|
|
||||||
|
def prepend_env_variables(environ, env_var_subfolders, workspaces):
|
||||||
|
"""Generate shell code to prepend environment variables for the all workspaces."""
|
||||||
|
lines = []
|
||||||
|
lines.append(comment('prepend folders of workspaces to environment variables'))
|
||||||
|
|
||||||
|
paths = [path for path in workspaces.split(os.pathsep) if path]
|
||||||
|
|
||||||
|
prefix = _prefix_env_variable(environ, 'CMAKE_PREFIX_PATH', paths, '')
|
||||||
|
lines.append(prepend(environ, 'CMAKE_PREFIX_PATH', prefix))
|
||||||
|
|
||||||
|
for key in sorted(key for key in env_var_subfolders.keys() if key != 'CMAKE_PREFIX_PATH'):
|
||||||
|
subfolder = env_var_subfolders[key]
|
||||||
|
prefix = _prefix_env_variable(environ, key, paths, subfolder)
|
||||||
|
lines.append(prepend(environ, key, prefix))
|
||||||
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
def _prefix_env_variable(environ, name, paths, subfolders):
|
||||||
|
"""
|
||||||
|
Return the prefix to prepend to the environment variable NAME.
|
||||||
|
|
||||||
|
Adding any path in NEW_PATHS_STR without creating duplicate or empty items.
|
||||||
|
"""
|
||||||
|
value = environ[name] if name in environ else ''
|
||||||
|
environ_paths = [path for path in value.split(os.pathsep) if path]
|
||||||
|
checked_paths = []
|
||||||
|
for path in paths:
|
||||||
|
if not isinstance(subfolders, list):
|
||||||
|
subfolders = [subfolders]
|
||||||
|
for subfolder in subfolders:
|
||||||
|
path_tmp = path
|
||||||
|
if subfolder:
|
||||||
|
path_tmp = os.path.join(path_tmp, subfolder)
|
||||||
|
# skip nonexistent paths
|
||||||
|
if not os.path.exists(path_tmp):
|
||||||
|
continue
|
||||||
|
# exclude any path already in env and any path we already added
|
||||||
|
if path_tmp not in environ_paths and path_tmp not in checked_paths:
|
||||||
|
checked_paths.append(path_tmp)
|
||||||
|
prefix_str = os.pathsep.join(checked_paths)
|
||||||
|
if prefix_str != '' and environ_paths:
|
||||||
|
prefix_str += os.pathsep
|
||||||
|
return prefix_str
|
||||||
|
|
||||||
|
|
||||||
|
def assignment(key, value):
|
||||||
|
if not IS_WINDOWS:
|
||||||
|
return 'export %s="%s"' % (key, value)
|
||||||
|
else:
|
||||||
|
return 'set %s=%s' % (key, value)
|
||||||
|
|
||||||
|
|
||||||
|
def comment(msg):
|
||||||
|
if not IS_WINDOWS:
|
||||||
|
return '# %s' % msg
|
||||||
|
else:
|
||||||
|
return 'REM %s' % msg
|
||||||
|
|
||||||
|
|
||||||
|
def prepend(environ, key, prefix):
|
||||||
|
if key not in environ or not environ[key]:
|
||||||
|
return assignment(key, prefix)
|
||||||
|
if not IS_WINDOWS:
|
||||||
|
return 'export %s="%s$%s"' % (key, prefix, key)
|
||||||
|
else:
|
||||||
|
return 'set %s=%s%%%s%%' % (key, prefix, key)
|
||||||
|
|
||||||
|
|
||||||
|
def find_env_hooks(environ, cmake_prefix_path):
|
||||||
|
"""Generate shell code with found environment hooks for the all workspaces."""
|
||||||
|
lines = []
|
||||||
|
lines.append(comment('found environment hooks in workspaces'))
|
||||||
|
|
||||||
|
generic_env_hooks = []
|
||||||
|
generic_env_hooks_workspace = []
|
||||||
|
specific_env_hooks = []
|
||||||
|
specific_env_hooks_workspace = []
|
||||||
|
generic_env_hooks_by_filename = {}
|
||||||
|
specific_env_hooks_by_filename = {}
|
||||||
|
generic_env_hook_ext = 'bat' if IS_WINDOWS else 'sh'
|
||||||
|
specific_env_hook_ext = environ['CATKIN_SHELL'] if not IS_WINDOWS and 'CATKIN_SHELL' in environ and environ['CATKIN_SHELL'] else None
|
||||||
|
# remove non-workspace paths
|
||||||
|
workspaces = [path for path in cmake_prefix_path.split(os.pathsep) if path and os.path.isfile(os.path.join(path, CATKIN_MARKER_FILE))]
|
||||||
|
for workspace in reversed(workspaces):
|
||||||
|
env_hook_dir = os.path.join(workspace, 'etc', 'catkin', 'profile.d')
|
||||||
|
if os.path.isdir(env_hook_dir):
|
||||||
|
for filename in sorted(os.listdir(env_hook_dir)):
|
||||||
|
if filename.endswith('.%s' % generic_env_hook_ext):
|
||||||
|
# remove previous env hook with same name if present
|
||||||
|
if filename in generic_env_hooks_by_filename:
|
||||||
|
i = generic_env_hooks.index(generic_env_hooks_by_filename[filename])
|
||||||
|
generic_env_hooks.pop(i)
|
||||||
|
generic_env_hooks_workspace.pop(i)
|
||||||
|
# append env hook
|
||||||
|
generic_env_hooks.append(os.path.join(env_hook_dir, filename))
|
||||||
|
generic_env_hooks_workspace.append(workspace)
|
||||||
|
generic_env_hooks_by_filename[filename] = generic_env_hooks[-1]
|
||||||
|
elif specific_env_hook_ext is not None and filename.endswith('.%s' % specific_env_hook_ext):
|
||||||
|
# remove previous env hook with same name if present
|
||||||
|
if filename in specific_env_hooks_by_filename:
|
||||||
|
i = specific_env_hooks.index(specific_env_hooks_by_filename[filename])
|
||||||
|
specific_env_hooks.pop(i)
|
||||||
|
specific_env_hooks_workspace.pop(i)
|
||||||
|
# append env hook
|
||||||
|
specific_env_hooks.append(os.path.join(env_hook_dir, filename))
|
||||||
|
specific_env_hooks_workspace.append(workspace)
|
||||||
|
specific_env_hooks_by_filename[filename] = specific_env_hooks[-1]
|
||||||
|
env_hooks = generic_env_hooks + specific_env_hooks
|
||||||
|
env_hooks_workspace = generic_env_hooks_workspace + specific_env_hooks_workspace
|
||||||
|
count = len(env_hooks)
|
||||||
|
lines.append(assignment('_CATKIN_ENVIRONMENT_HOOKS_COUNT', count))
|
||||||
|
for i in range(count):
|
||||||
|
lines.append(assignment('_CATKIN_ENVIRONMENT_HOOKS_%d' % i, env_hooks[i]))
|
||||||
|
lines.append(assignment('_CATKIN_ENVIRONMENT_HOOKS_%d_WORKSPACE' % i, env_hooks_workspace[i]))
|
||||||
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_arguments(args=None):
|
||||||
|
parser = argparse.ArgumentParser(description='Generates code blocks for the setup.SHELL script.')
|
||||||
|
parser.add_argument('--extend', action='store_true', help='Skip unsetting previous environment variables to extend context')
|
||||||
|
parser.add_argument('--local', action='store_true', help='Only consider this prefix path and ignore other prefix path in the environment')
|
||||||
|
return parser.parse_known_args(args=args)[0]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
args = _parse_arguments()
|
||||||
|
except Exception as e:
|
||||||
|
print(e, file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not args.local:
|
||||||
|
# environment at generation time
|
||||||
|
CMAKE_PREFIX_PATH = r'/home/firefly/obj_dec/devel;/home/firefly/pibot_ros/ros_ws/devel;/opt/ros/noetic'.split(';')
|
||||||
|
else:
|
||||||
|
# don't consider any other prefix path than this one
|
||||||
|
CMAKE_PREFIX_PATH = []
|
||||||
|
# prepend current workspace if not already part of CPP
|
||||||
|
base_path = os.path.dirname(__file__)
|
||||||
|
# CMAKE_PREFIX_PATH uses forward slash on all platforms, but __file__ is platform dependent
|
||||||
|
# base_path on Windows contains backward slashes, need to be converted to forward slashes before comparison
|
||||||
|
if os.path.sep != '/':
|
||||||
|
base_path = base_path.replace(os.path.sep, '/')
|
||||||
|
|
||||||
|
if base_path not in CMAKE_PREFIX_PATH:
|
||||||
|
CMAKE_PREFIX_PATH.insert(0, base_path)
|
||||||
|
CMAKE_PREFIX_PATH = os.pathsep.join(CMAKE_PREFIX_PATH)
|
||||||
|
|
||||||
|
environ = dict(os.environ)
|
||||||
|
lines = []
|
||||||
|
if not args.extend:
|
||||||
|
lines += rollback_env_variables(environ, ENV_VAR_SUBFOLDERS)
|
||||||
|
lines += prepend_env_variables(environ, ENV_VAR_SUBFOLDERS, CMAKE_PREFIX_PATH)
|
||||||
|
lines += find_env_hooks(environ, CMAKE_PREFIX_PATH)
|
||||||
|
print('\n'.join(lines))
|
||||||
|
|
||||||
|
# need to explicitly flush the output
|
||||||
|
sys.stdout.flush()
|
||||||
|
except IOError as e:
|
||||||
|
# and catch potential "broken pipe" if stdout is not writable
|
||||||
|
# which can happen when piping the output to a file but the disk is full
|
||||||
|
if e.errno == errno.EPIPE:
|
||||||
|
print(e, file=sys.stderr)
|
||||||
|
sys.exit(2)
|
||||||
|
raise
|
||||||
|
|
||||||
|
sys.exit(0)
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
# generated from catkin/cmake/templates/env.sh.in
|
||||||
|
|
||||||
|
if [ $# -eq 0 ] ; then
|
||||||
|
/bin/echo "Usage: env.sh COMMANDS"
|
||||||
|
/bin/echo "Calling env.sh without arguments is not supported anymore. Instead spawn a subshell and source a setup file manually."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ensure to not use different shell type which was set before
|
||||||
|
CATKIN_SHELL=sh
|
||||||
|
|
||||||
|
# source setup.sh from same directory as this file
|
||||||
|
_CATKIN_SETUP_DIR=$(cd "`dirname "$0"`" > /dev/null && pwd)
|
||||||
|
. "$_CATKIN_SETUP_DIR/setup.sh"
|
||||||
|
exec "$@"
|
|
@ -0,0 +1,225 @@
|
||||||
|
// Generated by gencpp from file rknn_yolov5_demo/dis_info.msg
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef RKNN_YOLOV5_DEMO_MESSAGE_DIS_INFO_H
|
||||||
|
#define RKNN_YOLOV5_DEMO_MESSAGE_DIS_INFO_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <ros/types.h>
|
||||||
|
#include <ros/serialization.h>
|
||||||
|
#include <ros/builtin_message_traits.h>
|
||||||
|
#include <ros/message_operations.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace rknn_yolov5_demo
|
||||||
|
{
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct dis_info_
|
||||||
|
{
|
||||||
|
typedef dis_info_<ContainerAllocator> Type;
|
||||||
|
|
||||||
|
dis_info_()
|
||||||
|
: distance(0.0)
|
||||||
|
, width(0.0)
|
||||||
|
, height(0.0)
|
||||||
|
, angle(0.0) {
|
||||||
|
}
|
||||||
|
dis_info_(const ContainerAllocator& _alloc)
|
||||||
|
: distance(0.0)
|
||||||
|
, width(0.0)
|
||||||
|
, height(0.0)
|
||||||
|
, angle(0.0) {
|
||||||
|
(void)_alloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef float _distance_type;
|
||||||
|
_distance_type distance;
|
||||||
|
|
||||||
|
typedef float _width_type;
|
||||||
|
_width_type width;
|
||||||
|
|
||||||
|
typedef float _height_type;
|
||||||
|
_height_type height;
|
||||||
|
|
||||||
|
typedef float _angle_type;
|
||||||
|
_angle_type angle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef boost::shared_ptr< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> > Ptr;
|
||||||
|
typedef boost::shared_ptr< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> const> ConstPtr;
|
||||||
|
|
||||||
|
}; // struct dis_info_
|
||||||
|
|
||||||
|
typedef ::rknn_yolov5_demo::dis_info_<std::allocator<void> > dis_info;
|
||||||
|
|
||||||
|
typedef boost::shared_ptr< ::rknn_yolov5_demo::dis_info > dis_infoPtr;
|
||||||
|
typedef boost::shared_ptr< ::rknn_yolov5_demo::dis_info const> dis_infoConstPtr;
|
||||||
|
|
||||||
|
// constants requiring out of line definition
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<typename ContainerAllocator>
|
||||||
|
std::ostream& operator<<(std::ostream& s, const ::rknn_yolov5_demo::dis_info_<ContainerAllocator> & v)
|
||||||
|
{
|
||||||
|
ros::message_operations::Printer< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >::stream(s, "", v);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename ContainerAllocator1, typename ContainerAllocator2>
|
||||||
|
bool operator==(const ::rknn_yolov5_demo::dis_info_<ContainerAllocator1> & lhs, const ::rknn_yolov5_demo::dis_info_<ContainerAllocator2> & rhs)
|
||||||
|
{
|
||||||
|
return lhs.distance == rhs.distance &&
|
||||||
|
lhs.width == rhs.width &&
|
||||||
|
lhs.height == rhs.height &&
|
||||||
|
lhs.angle == rhs.angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ContainerAllocator1, typename ContainerAllocator2>
|
||||||
|
bool operator!=(const ::rknn_yolov5_demo::dis_info_<ContainerAllocator1> & lhs, const ::rknn_yolov5_demo::dis_info_<ContainerAllocator2> & rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace rknn_yolov5_demo
|
||||||
|
|
||||||
|
namespace ros
|
||||||
|
{
|
||||||
|
namespace message_traits
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct IsMessage< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >
|
||||||
|
: TrueType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct IsMessage< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> const>
|
||||||
|
: TrueType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct IsFixedSize< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >
|
||||||
|
: TrueType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct IsFixedSize< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> const>
|
||||||
|
: TrueType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct HasHeader< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >
|
||||||
|
: FalseType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct HasHeader< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> const>
|
||||||
|
: FalseType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
|
||||||
|
template<class ContainerAllocator>
|
||||||
|
struct MD5Sum< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
static const char* value()
|
||||||
|
{
|
||||||
|
return "941a1dedbc0595405760672b9f7f50ee";
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* value(const ::rknn_yolov5_demo::dis_info_<ContainerAllocator>&) { return value(); }
|
||||||
|
static const uint64_t static_value1 = 0x941a1dedbc059540ULL;
|
||||||
|
static const uint64_t static_value2 = 0x5760672b9f7f50eeULL;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class ContainerAllocator>
|
||||||
|
struct DataType< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
static const char* value()
|
||||||
|
{
|
||||||
|
return "rknn_yolov5_demo/dis_info";
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* value(const ::rknn_yolov5_demo::dis_info_<ContainerAllocator>&) { return value(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class ContainerAllocator>
|
||||||
|
struct Definition< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
static const char* value()
|
||||||
|
{
|
||||||
|
return "float32 distance\n"
|
||||||
|
"float32 width\n"
|
||||||
|
"float32 height\n"
|
||||||
|
"float32 angle\n"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* value(const ::rknn_yolov5_demo::dis_info_<ContainerAllocator>&) { return value(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace message_traits
|
||||||
|
} // namespace ros
|
||||||
|
|
||||||
|
namespace ros
|
||||||
|
{
|
||||||
|
namespace serialization
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class ContainerAllocator> struct Serializer< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
|
||||||
|
{
|
||||||
|
stream.next(m.distance);
|
||||||
|
stream.next(m.width);
|
||||||
|
stream.next(m.height);
|
||||||
|
stream.next(m.angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
ROS_DECLARE_ALLINONE_SERIALIZER
|
||||||
|
}; // struct dis_info_
|
||||||
|
|
||||||
|
} // namespace serialization
|
||||||
|
} // namespace ros
|
||||||
|
|
||||||
|
namespace ros
|
||||||
|
{
|
||||||
|
namespace message_operations
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class ContainerAllocator>
|
||||||
|
struct Printer< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::rknn_yolov5_demo::dis_info_<ContainerAllocator>& v)
|
||||||
|
{
|
||||||
|
s << indent << "distance: ";
|
||||||
|
Printer<float>::stream(s, indent + " ", v.distance);
|
||||||
|
s << indent << "width: ";
|
||||||
|
Printer<float>::stream(s, indent + " ", v.width);
|
||||||
|
s << indent << "height: ";
|
||||||
|
Printer<float>::stream(s, indent + " ", v.height);
|
||||||
|
s << indent << "angle: ";
|
||||||
|
Printer<float>::stream(s, indent + " ", v.angle);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace message_operations
|
||||||
|
} // namespace ros
|
||||||
|
|
||||||
|
#endif // RKNN_YOLOV5_DEMO_MESSAGE_DIS_INFO_H
|
|
@ -0,0 +1,208 @@
|
||||||
|
// Generated by gencpp from file rknn_yolov5_demo/dis_info_array.msg
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef RKNN_YOLOV5_DEMO_MESSAGE_DIS_INFO_ARRAY_H
|
||||||
|
#define RKNN_YOLOV5_DEMO_MESSAGE_DIS_INFO_ARRAY_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <ros/types.h>
|
||||||
|
#include <ros/serialization.h>
|
||||||
|
#include <ros/builtin_message_traits.h>
|
||||||
|
#include <ros/message_operations.h>
|
||||||
|
|
||||||
|
#include <rknn_yolov5_demo/dis_info.h>
|
||||||
|
|
||||||
|
namespace rknn_yolov5_demo
|
||||||
|
{
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct dis_info_array_
|
||||||
|
{
|
||||||
|
typedef dis_info_array_<ContainerAllocator> Type;
|
||||||
|
|
||||||
|
dis_info_array_()
|
||||||
|
: dis() {
|
||||||
|
}
|
||||||
|
dis_info_array_(const ContainerAllocator& _alloc)
|
||||||
|
: dis(_alloc) {
|
||||||
|
(void)_alloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef std::vector< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> , typename std::allocator_traits<ContainerAllocator>::template rebind_alloc< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >> _dis_type;
|
||||||
|
_dis_type dis;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef boost::shared_ptr< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> > Ptr;
|
||||||
|
typedef boost::shared_ptr< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> const> ConstPtr;
|
||||||
|
|
||||||
|
}; // struct dis_info_array_
|
||||||
|
|
||||||
|
typedef ::rknn_yolov5_demo::dis_info_array_<std::allocator<void> > dis_info_array;
|
||||||
|
|
||||||
|
typedef boost::shared_ptr< ::rknn_yolov5_demo::dis_info_array > dis_info_arrayPtr;
|
||||||
|
typedef boost::shared_ptr< ::rknn_yolov5_demo::dis_info_array const> dis_info_arrayConstPtr;
|
||||||
|
|
||||||
|
// constants requiring out of line definition
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<typename ContainerAllocator>
|
||||||
|
std::ostream& operator<<(std::ostream& s, const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> & v)
|
||||||
|
{
|
||||||
|
ros::message_operations::Printer< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >::stream(s, "", v);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename ContainerAllocator1, typename ContainerAllocator2>
|
||||||
|
bool operator==(const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator1> & lhs, const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator2> & rhs)
|
||||||
|
{
|
||||||
|
return lhs.dis == rhs.dis;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ContainerAllocator1, typename ContainerAllocator2>
|
||||||
|
bool operator!=(const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator1> & lhs, const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator2> & rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace rknn_yolov5_demo
|
||||||
|
|
||||||
|
namespace ros
|
||||||
|
{
|
||||||
|
namespace message_traits
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct IsMessage< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >
|
||||||
|
: TrueType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct IsMessage< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> const>
|
||||||
|
: TrueType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct IsFixedSize< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >
|
||||||
|
: FalseType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct IsFixedSize< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> const>
|
||||||
|
: FalseType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct HasHeader< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >
|
||||||
|
: FalseType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
template <class ContainerAllocator>
|
||||||
|
struct HasHeader< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> const>
|
||||||
|
: FalseType
|
||||||
|
{ };
|
||||||
|
|
||||||
|
|
||||||
|
template<class ContainerAllocator>
|
||||||
|
struct MD5Sum< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
static const char* value()
|
||||||
|
{
|
||||||
|
return "154c19253095a5ca966c5dce84293342";
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* value(const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator>&) { return value(); }
|
||||||
|
static const uint64_t static_value1 = 0x154c19253095a5caULL;
|
||||||
|
static const uint64_t static_value2 = 0x966c5dce84293342ULL;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class ContainerAllocator>
|
||||||
|
struct DataType< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
static const char* value()
|
||||||
|
{
|
||||||
|
return "rknn_yolov5_demo/dis_info_array";
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* value(const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator>&) { return value(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class ContainerAllocator>
|
||||||
|
struct Definition< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
static const char* value()
|
||||||
|
{
|
||||||
|
return "rknn_yolov5_demo/dis_info[] dis\n"
|
||||||
|
"================================================================================\n"
|
||||||
|
"MSG: rknn_yolov5_demo/dis_info\n"
|
||||||
|
"float32 distance\n"
|
||||||
|
"float32 width\n"
|
||||||
|
"float32 height\n"
|
||||||
|
"float32 angle\n"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* value(const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator>&) { return value(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace message_traits
|
||||||
|
} // namespace ros
|
||||||
|
|
||||||
|
namespace ros
|
||||||
|
{
|
||||||
|
namespace serialization
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class ContainerAllocator> struct Serializer< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
|
||||||
|
{
|
||||||
|
stream.next(m.dis);
|
||||||
|
}
|
||||||
|
|
||||||
|
ROS_DECLARE_ALLINONE_SERIALIZER
|
||||||
|
}; // struct dis_info_array_
|
||||||
|
|
||||||
|
} // namespace serialization
|
||||||
|
} // namespace ros
|
||||||
|
|
||||||
|
namespace ros
|
||||||
|
{
|
||||||
|
namespace message_operations
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class ContainerAllocator>
|
||||||
|
struct Printer< ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator> >
|
||||||
|
{
|
||||||
|
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::rknn_yolov5_demo::dis_info_array_<ContainerAllocator>& v)
|
||||||
|
{
|
||||||
|
s << indent << "dis[]" << std::endl;
|
||||||
|
for (size_t i = 0; i < v.dis.size(); ++i)
|
||||||
|
{
|
||||||
|
s << indent << " dis[" << i << "]: ";
|
||||||
|
s << std::endl;
|
||||||
|
s << indent;
|
||||||
|
Printer< ::rknn_yolov5_demo::dis_info_<ContainerAllocator> >::stream(s, indent + " ", v.dis[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace message_operations
|
||||||
|
} // namespace ros
|
||||||
|
|
||||||
|
#endif // RKNN_YOLOV5_DEMO_MESSAGE_DIS_INFO_ARRAY_H
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
||||||
|
prefix=/home/firefly/obj_dec/devel
|
||||||
|
|
||||||
|
Name: rknn_yolov5_demo
|
||||||
|
Description: Description of rknn_yolov5_demo
|
||||||
|
Version: 0.0.0
|
||||||
|
Cflags: -I/home/firefly/obj_dec/devel/include
|
||||||
|
Libs: -L${prefix}/lib
|
||||||
|
Requires: roscpp std_msgs message_runtime
|
|
@ -0,0 +1,2 @@
|
||||||
|
from ._dis_info import *
|
||||||
|
from ._dis_info_array import *
|
|
@ -0,0 +1,127 @@
|
||||||
|
# This Python file uses the following encoding: utf-8
|
||||||
|
"""autogenerated by genpy from rknn_yolov5_demo/dis_info.msg. Do not edit."""
|
||||||
|
import codecs
|
||||||
|
import sys
|
||||||
|
python3 = True if sys.hexversion > 0x03000000 else False
|
||||||
|
import genpy
|
||||||
|
import struct
|
||||||
|
|
||||||
|
|
||||||
|
class dis_info(genpy.Message):
|
||||||
|
_md5sum = "941a1dedbc0595405760672b9f7f50ee"
|
||||||
|
_type = "rknn_yolov5_demo/dis_info"
|
||||||
|
_has_header = False # flag to mark the presence of a Header object
|
||||||
|
_full_text = """float32 distance
|
||||||
|
float32 width
|
||||||
|
float32 height
|
||||||
|
float32 angle
|
||||||
|
"""
|
||||||
|
__slots__ = ['distance','width','height','angle']
|
||||||
|
_slot_types = ['float32','float32','float32','float32']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwds):
|
||||||
|
"""
|
||||||
|
Constructor. Any message fields that are implicitly/explicitly
|
||||||
|
set to None will be assigned a default value. The recommend
|
||||||
|
use is keyword arguments as this is more robust to future message
|
||||||
|
changes. You cannot mix in-order arguments and keyword arguments.
|
||||||
|
|
||||||
|
The available fields are:
|
||||||
|
distance,width,height,angle
|
||||||
|
|
||||||
|
:param args: complete set of field values, in .msg order
|
||||||
|
:param kwds: use keyword arguments corresponding to message field names
|
||||||
|
to set specific fields.
|
||||||
|
"""
|
||||||
|
if args or kwds:
|
||||||
|
super(dis_info, self).__init__(*args, **kwds)
|
||||||
|
# message fields cannot be None, assign default values for those that are
|
||||||
|
if self.distance is None:
|
||||||
|
self.distance = 0.
|
||||||
|
if self.width is None:
|
||||||
|
self.width = 0.
|
||||||
|
if self.height is None:
|
||||||
|
self.height = 0.
|
||||||
|
if self.angle is None:
|
||||||
|
self.angle = 0.
|
||||||
|
else:
|
||||||
|
self.distance = 0.
|
||||||
|
self.width = 0.
|
||||||
|
self.height = 0.
|
||||||
|
self.angle = 0.
|
||||||
|
|
||||||
|
def _get_types(self):
|
||||||
|
"""
|
||||||
|
internal API method
|
||||||
|
"""
|
||||||
|
return self._slot_types
|
||||||
|
|
||||||
|
def serialize(self, buff):
|
||||||
|
"""
|
||||||
|
serialize message into buffer
|
||||||
|
:param buff: buffer, ``StringIO``
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
_x = self
|
||||||
|
buff.write(_get_struct_4f().pack(_x.distance, _x.width, _x.height, _x.angle))
|
||||||
|
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
|
||||||
|
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
|
||||||
|
|
||||||
|
def deserialize(self, str):
|
||||||
|
"""
|
||||||
|
unpack serialized message in str into this message instance
|
||||||
|
:param str: byte array of serialized message, ``str``
|
||||||
|
"""
|
||||||
|
if python3:
|
||||||
|
codecs.lookup_error("rosmsg").msg_type = self._type
|
||||||
|
try:
|
||||||
|
end = 0
|
||||||
|
_x = self
|
||||||
|
start = end
|
||||||
|
end += 16
|
||||||
|
(_x.distance, _x.width, _x.height, _x.angle,) = _get_struct_4f().unpack(str[start:end])
|
||||||
|
return self
|
||||||
|
except struct.error as e:
|
||||||
|
raise genpy.DeserializationError(e) # most likely buffer underfill
|
||||||
|
|
||||||
|
|
||||||
|
def serialize_numpy(self, buff, numpy):
|
||||||
|
"""
|
||||||
|
serialize message with numpy array types into buffer
|
||||||
|
:param buff: buffer, ``StringIO``
|
||||||
|
:param numpy: numpy python module
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
_x = self
|
||||||
|
buff.write(_get_struct_4f().pack(_x.distance, _x.width, _x.height, _x.angle))
|
||||||
|
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
|
||||||
|
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
|
||||||
|
|
||||||
|
def deserialize_numpy(self, str, numpy):
|
||||||
|
"""
|
||||||
|
unpack serialized message in str into this message instance using numpy for array types
|
||||||
|
:param str: byte array of serialized message, ``str``
|
||||||
|
:param numpy: numpy python module
|
||||||
|
"""
|
||||||
|
if python3:
|
||||||
|
codecs.lookup_error("rosmsg").msg_type = self._type
|
||||||
|
try:
|
||||||
|
end = 0
|
||||||
|
_x = self
|
||||||
|
start = end
|
||||||
|
end += 16
|
||||||
|
(_x.distance, _x.width, _x.height, _x.angle,) = _get_struct_4f().unpack(str[start:end])
|
||||||
|
return self
|
||||||
|
except struct.error as e:
|
||||||
|
raise genpy.DeserializationError(e) # most likely buffer underfill
|
||||||
|
|
||||||
|
_struct_I = genpy.struct_I
|
||||||
|
def _get_struct_I():
|
||||||
|
global _struct_I
|
||||||
|
return _struct_I
|
||||||
|
_struct_4f = None
|
||||||
|
def _get_struct_4f():
|
||||||
|
global _struct_4f
|
||||||
|
if _struct_4f is None:
|
||||||
|
_struct_4f = struct.Struct("<4f")
|
||||||
|
return _struct_4f
|
|
@ -0,0 +1,146 @@
|
||||||
|
# This Python file uses the following encoding: utf-8
|
||||||
|
"""autogenerated by genpy from rknn_yolov5_demo/dis_info_array.msg. Do not edit."""
|
||||||
|
import codecs
|
||||||
|
import sys
|
||||||
|
python3 = True if sys.hexversion > 0x03000000 else False
|
||||||
|
import genpy
|
||||||
|
import struct
|
||||||
|
|
||||||
|
import rknn_yolov5_demo.msg
|
||||||
|
|
||||||
|
class dis_info_array(genpy.Message):
|
||||||
|
_md5sum = "154c19253095a5ca966c5dce84293342"
|
||||||
|
_type = "rknn_yolov5_demo/dis_info_array"
|
||||||
|
_has_header = False # flag to mark the presence of a Header object
|
||||||
|
_full_text = """rknn_yolov5_demo/dis_info[] dis
|
||||||
|
================================================================================
|
||||||
|
MSG: rknn_yolov5_demo/dis_info
|
||||||
|
float32 distance
|
||||||
|
float32 width
|
||||||
|
float32 height
|
||||||
|
float32 angle
|
||||||
|
"""
|
||||||
|
__slots__ = ['dis']
|
||||||
|
_slot_types = ['rknn_yolov5_demo/dis_info[]']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwds):
|
||||||
|
"""
|
||||||
|
Constructor. Any message fields that are implicitly/explicitly
|
||||||
|
set to None will be assigned a default value. The recommend
|
||||||
|
use is keyword arguments as this is more robust to future message
|
||||||
|
changes. You cannot mix in-order arguments and keyword arguments.
|
||||||
|
|
||||||
|
The available fields are:
|
||||||
|
dis
|
||||||
|
|
||||||
|
:param args: complete set of field values, in .msg order
|
||||||
|
:param kwds: use keyword arguments corresponding to message field names
|
||||||
|
to set specific fields.
|
||||||
|
"""
|
||||||
|
if args or kwds:
|
||||||
|
super(dis_info_array, self).__init__(*args, **kwds)
|
||||||
|
# message fields cannot be None, assign default values for those that are
|
||||||
|
if self.dis is None:
|
||||||
|
self.dis = []
|
||||||
|
else:
|
||||||
|
self.dis = []
|
||||||
|
|
||||||
|
def _get_types(self):
|
||||||
|
"""
|
||||||
|
internal API method
|
||||||
|
"""
|
||||||
|
return self._slot_types
|
||||||
|
|
||||||
|
def serialize(self, buff):
|
||||||
|
"""
|
||||||
|
serialize message into buffer
|
||||||
|
:param buff: buffer, ``StringIO``
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
length = len(self.dis)
|
||||||
|
buff.write(_struct_I.pack(length))
|
||||||
|
for val1 in self.dis:
|
||||||
|
_x = val1
|
||||||
|
buff.write(_get_struct_4f().pack(_x.distance, _x.width, _x.height, _x.angle))
|
||||||
|
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
|
||||||
|
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
|
||||||
|
|
||||||
|
def deserialize(self, str):
|
||||||
|
"""
|
||||||
|
unpack serialized message in str into this message instance
|
||||||
|
:param str: byte array of serialized message, ``str``
|
||||||
|
"""
|
||||||
|
if python3:
|
||||||
|
codecs.lookup_error("rosmsg").msg_type = self._type
|
||||||
|
try:
|
||||||
|
if self.dis is None:
|
||||||
|
self.dis = None
|
||||||
|
end = 0
|
||||||
|
start = end
|
||||||
|
end += 4
|
||||||
|
(length,) = _struct_I.unpack(str[start:end])
|
||||||
|
self.dis = []
|
||||||
|
for i in range(0, length):
|
||||||
|
val1 = rknn_yolov5_demo.msg.dis_info()
|
||||||
|
_x = val1
|
||||||
|
start = end
|
||||||
|
end += 16
|
||||||
|
(_x.distance, _x.width, _x.height, _x.angle,) = _get_struct_4f().unpack(str[start:end])
|
||||||
|
self.dis.append(val1)
|
||||||
|
return self
|
||||||
|
except struct.error as e:
|
||||||
|
raise genpy.DeserializationError(e) # most likely buffer underfill
|
||||||
|
|
||||||
|
|
||||||
|
def serialize_numpy(self, buff, numpy):
|
||||||
|
"""
|
||||||
|
serialize message with numpy array types into buffer
|
||||||
|
:param buff: buffer, ``StringIO``
|
||||||
|
:param numpy: numpy python module
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
length = len(self.dis)
|
||||||
|
buff.write(_struct_I.pack(length))
|
||||||
|
for val1 in self.dis:
|
||||||
|
_x = val1
|
||||||
|
buff.write(_get_struct_4f().pack(_x.distance, _x.width, _x.height, _x.angle))
|
||||||
|
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
|
||||||
|
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
|
||||||
|
|
||||||
|
def deserialize_numpy(self, str, numpy):
|
||||||
|
"""
|
||||||
|
unpack serialized message in str into this message instance using numpy for array types
|
||||||
|
:param str: byte array of serialized message, ``str``
|
||||||
|
:param numpy: numpy python module
|
||||||
|
"""
|
||||||
|
if python3:
|
||||||
|
codecs.lookup_error("rosmsg").msg_type = self._type
|
||||||
|
try:
|
||||||
|
if self.dis is None:
|
||||||
|
self.dis = None
|
||||||
|
end = 0
|
||||||
|
start = end
|
||||||
|
end += 4
|
||||||
|
(length,) = _struct_I.unpack(str[start:end])
|
||||||
|
self.dis = []
|
||||||
|
for i in range(0, length):
|
||||||
|
val1 = rknn_yolov5_demo.msg.dis_info()
|
||||||
|
_x = val1
|
||||||
|
start = end
|
||||||
|
end += 16
|
||||||
|
(_x.distance, _x.width, _x.height, _x.angle,) = _get_struct_4f().unpack(str[start:end])
|
||||||
|
self.dis.append(val1)
|
||||||
|
return self
|
||||||
|
except struct.error as e:
|
||||||
|
raise genpy.DeserializationError(e) # most likely buffer underfill
|
||||||
|
|
||||||
|
_struct_I = genpy.struct_I
|
||||||
|
def _get_struct_I():
|
||||||
|
global _struct_I
|
||||||
|
return _struct_I
|
||||||
|
_struct_4f = None
|
||||||
|
def _get_struct_4f():
|
||||||
|
global _struct_4f
|
||||||
|
if _struct_4f is None:
|
||||||
|
_struct_4f = struct.Struct("<4f")
|
||||||
|
return _struct_4f
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# generated from catkin/cmake/templates/local_setup.bash.in
|
||||||
|
|
||||||
|
CATKIN_SHELL=bash
|
||||||
|
|
||||||
|
# source setup.sh from same directory as this file
|
||||||
|
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
|
||||||
|
. "$_CATKIN_SETUP_DIR/setup.sh" --extend --local
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
# generated from catkin/cmake/template/local_setup.sh.in
|
||||||
|
|
||||||
|
# since this file is sourced either use the provided _CATKIN_SETUP_DIR
|
||||||
|
# or fall back to the destination set at configure time
|
||||||
|
: ${_CATKIN_SETUP_DIR:=/home/firefly/obj_dec/devel}
|
||||||
|
CATKIN_SETUP_UTIL_ARGS="--extend --local"
|
||||||
|
. "$_CATKIN_SETUP_DIR/setup.sh"
|
||||||
|
unset CATKIN_SETUP_UTIL_ARGS
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
# generated from catkin/cmake/templates/local_setup.zsh.in
|
||||||
|
|
||||||
|
CATKIN_SHELL=zsh
|
||||||
|
|
||||||
|
# source setup.sh from same directory as this file
|
||||||
|
_CATKIN_SETUP_DIR=$(builtin cd -q "`dirname "$0"`" > /dev/null && pwd)
|
||||||
|
emulate -R zsh -c 'source "$_CATKIN_SETUP_DIR/setup.sh" --extend --local'
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# generated from catkin/cmake/templates/setup.bash.in
|
||||||
|
|
||||||
|
CATKIN_SHELL=bash
|
||||||
|
|
||||||
|
# source setup.sh from same directory as this file
|
||||||
|
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
|
||||||
|
. "$_CATKIN_SETUP_DIR/setup.sh"
|
|
@ -0,0 +1,96 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
# generated from catkin/cmake/template/setup.sh.in
|
||||||
|
|
||||||
|
# Sets various environment variables and sources additional environment hooks.
|
||||||
|
# It tries it's best to undo changes from a previously sourced setup file before.
|
||||||
|
# Supported command line options:
|
||||||
|
# --extend: skips the undoing of changes from a previously sourced setup file
|
||||||
|
# --local: only considers this workspace but not the chained ones
|
||||||
|
# In plain sh shell which doesn't support arguments for sourced scripts you can
|
||||||
|
# set the environment variable `CATKIN_SETUP_UTIL_ARGS=--extend/--local` instead.
|
||||||
|
|
||||||
|
# since this file is sourced either use the provided _CATKIN_SETUP_DIR
|
||||||
|
# or fall back to the destination set at configure time
|
||||||
|
: ${_CATKIN_SETUP_DIR:=/home/firefly/obj_dec/devel}
|
||||||
|
_SETUP_UTIL="$_CATKIN_SETUP_DIR/_setup_util.py"
|
||||||
|
unset _CATKIN_SETUP_DIR
|
||||||
|
|
||||||
|
if [ ! -f "$_SETUP_UTIL" ]; then
|
||||||
|
echo "Missing Python script: $_SETUP_UTIL"
|
||||||
|
return 22
|
||||||
|
fi
|
||||||
|
|
||||||
|
# detect if running on Darwin platform
|
||||||
|
_UNAME=`uname -s`
|
||||||
|
_IS_DARWIN=0
|
||||||
|
if [ "$_UNAME" = "Darwin" ]; then
|
||||||
|
_IS_DARWIN=1
|
||||||
|
fi
|
||||||
|
unset _UNAME
|
||||||
|
|
||||||
|
# make sure to export all environment variables
|
||||||
|
export CMAKE_PREFIX_PATH
|
||||||
|
if [ $_IS_DARWIN -eq 0 ]; then
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
else
|
||||||
|
export DYLD_LIBRARY_PATH
|
||||||
|
fi
|
||||||
|
unset _IS_DARWIN
|
||||||
|
export PATH
|
||||||
|
export PKG_CONFIG_PATH
|
||||||
|
export PYTHONPATH
|
||||||
|
|
||||||
|
# remember type of shell if not already set
|
||||||
|
if [ -z "$CATKIN_SHELL" ]; then
|
||||||
|
CATKIN_SHELL=sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# invoke Python script to generate necessary exports of environment variables
|
||||||
|
# use TMPDIR if it exists, otherwise fall back to /tmp
|
||||||
|
if [ -d "${TMPDIR:-}" ]; then
|
||||||
|
_TMPDIR="${TMPDIR}"
|
||||||
|
else
|
||||||
|
_TMPDIR=/tmp
|
||||||
|
fi
|
||||||
|
_SETUP_TMP=`mktemp "${_TMPDIR}/setup.sh.XXXXXXXXXX"`
|
||||||
|
unset _TMPDIR
|
||||||
|
if [ $? -ne 0 -o ! -f "$_SETUP_TMP" ]; then
|
||||||
|
echo "Could not create temporary file: $_SETUP_TMP"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
CATKIN_SHELL=$CATKIN_SHELL "$_SETUP_UTIL" $@ ${CATKIN_SETUP_UTIL_ARGS:-} >> "$_SETUP_TMP"
|
||||||
|
_RC=$?
|
||||||
|
if [ $_RC -ne 0 ]; then
|
||||||
|
if [ $_RC -eq 2 ]; then
|
||||||
|
echo "Could not write the output of '$_SETUP_UTIL' to temporary file '$_SETUP_TMP': may be the disk if full?"
|
||||||
|
else
|
||||||
|
echo "Failed to run '\"$_SETUP_UTIL\" $@': return code $_RC"
|
||||||
|
fi
|
||||||
|
unset _RC
|
||||||
|
unset _SETUP_UTIL
|
||||||
|
rm -f "$_SETUP_TMP"
|
||||||
|
unset _SETUP_TMP
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
unset _RC
|
||||||
|
unset _SETUP_UTIL
|
||||||
|
. "$_SETUP_TMP"
|
||||||
|
rm -f "$_SETUP_TMP"
|
||||||
|
unset _SETUP_TMP
|
||||||
|
|
||||||
|
# source all environment hooks
|
||||||
|
_i=0
|
||||||
|
while [ $_i -lt $_CATKIN_ENVIRONMENT_HOOKS_COUNT ]; do
|
||||||
|
eval _envfile=\$_CATKIN_ENVIRONMENT_HOOKS_$_i
|
||||||
|
unset _CATKIN_ENVIRONMENT_HOOKS_$_i
|
||||||
|
eval _envfile_workspace=\$_CATKIN_ENVIRONMENT_HOOKS_${_i}_WORKSPACE
|
||||||
|
unset _CATKIN_ENVIRONMENT_HOOKS_${_i}_WORKSPACE
|
||||||
|
# set workspace for environment hook
|
||||||
|
CATKIN_ENV_HOOK_WORKSPACE=$_envfile_workspace
|
||||||
|
. "$_envfile"
|
||||||
|
unset CATKIN_ENV_HOOK_WORKSPACE
|
||||||
|
_i=$((_i + 1))
|
||||||
|
done
|
||||||
|
unset _i
|
||||||
|
|
||||||
|
unset _CATKIN_ENVIRONMENT_HOOKS_COUNT
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
# generated from catkin/cmake/templates/setup.zsh.in
|
||||||
|
|
||||||
|
CATKIN_SHELL=zsh
|
||||||
|
|
||||||
|
# source setup.sh from same directory as this file
|
||||||
|
_CATKIN_SETUP_DIR=$(builtin cd -q "`dirname "$0"`" > /dev/null && pwd)
|
||||||
|
emulate -R zsh -c 'source "$_CATKIN_SETUP_DIR/setup.sh"'
|
|
@ -0,0 +1,9 @@
|
||||||
|
(cl:defpackage rknn_yolov5_demo-msg
|
||||||
|
(:use )
|
||||||
|
(:export
|
||||||
|
"<DIS_INFO>"
|
||||||
|
"DIS_INFO"
|
||||||
|
"<DIS_INFO_ARRAY>"
|
||||||
|
"DIS_INFO_ARRAY"
|
||||||
|
))
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
(cl:in-package rknn_yolov5_demo-msg)
|
||||||
|
(cl:export '(DISTANCE-VAL
|
||||||
|
DISTANCE
|
||||||
|
WIDTH-VAL
|
||||||
|
WIDTH
|
||||||
|
HEIGHT-VAL
|
||||||
|
HEIGHT
|
||||||
|
ANGLE-VAL
|
||||||
|
ANGLE
|
||||||
|
))
|
|
@ -0,0 +1,4 @@
|
||||||
|
(cl:in-package rknn_yolov5_demo-msg)
|
||||||
|
(cl:export '(DIS-VAL
|
||||||
|
DIS
|
||||||
|
))
|
|
@ -0,0 +1,142 @@
|
||||||
|
; Auto-generated. Do not edit!
|
||||||
|
|
||||||
|
|
||||||
|
(cl:in-package rknn_yolov5_demo-msg)
|
||||||
|
|
||||||
|
|
||||||
|
;//! \htmlinclude dis_info.msg.html
|
||||||
|
|
||||||
|
(cl:defclass <dis_info> (roslisp-msg-protocol:ros-message)
|
||||||
|
((distance
|
||||||
|
:reader distance
|
||||||
|
:initarg :distance
|
||||||
|
:type cl:float
|
||||||
|
:initform 0.0)
|
||||||
|
(width
|
||||||
|
:reader width
|
||||||
|
:initarg :width
|
||||||
|
:type cl:float
|
||||||
|
:initform 0.0)
|
||||||
|
(height
|
||||||
|
:reader height
|
||||||
|
:initarg :height
|
||||||
|
:type cl:float
|
||||||
|
:initform 0.0)
|
||||||
|
(angle
|
||||||
|
:reader angle
|
||||||
|
:initarg :angle
|
||||||
|
:type cl:float
|
||||||
|
:initform 0.0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(cl:defclass dis_info (<dis_info>)
|
||||||
|
())
|
||||||
|
|
||||||
|
(cl:defmethod cl:initialize-instance :after ((m <dis_info>) cl:&rest args)
|
||||||
|
(cl:declare (cl:ignorable args))
|
||||||
|
(cl:unless (cl:typep m 'dis_info)
|
||||||
|
(roslisp-msg-protocol:msg-deprecation-warning "using old message class name rknn_yolov5_demo-msg:<dis_info> is deprecated: use rknn_yolov5_demo-msg:dis_info instead.")))
|
||||||
|
|
||||||
|
(cl:ensure-generic-function 'distance-val :lambda-list '(m))
|
||||||
|
(cl:defmethod distance-val ((m <dis_info>))
|
||||||
|
(roslisp-msg-protocol:msg-deprecation-warning "Using old-style slot reader rknn_yolov5_demo-msg:distance-val is deprecated. Use rknn_yolov5_demo-msg:distance instead.")
|
||||||
|
(distance m))
|
||||||
|
|
||||||
|
(cl:ensure-generic-function 'width-val :lambda-list '(m))
|
||||||
|
(cl:defmethod width-val ((m <dis_info>))
|
||||||
|
(roslisp-msg-protocol:msg-deprecation-warning "Using old-style slot reader rknn_yolov5_demo-msg:width-val is deprecated. Use rknn_yolov5_demo-msg:width instead.")
|
||||||
|
(width m))
|
||||||
|
|
||||||
|
(cl:ensure-generic-function 'height-val :lambda-list '(m))
|
||||||
|
(cl:defmethod height-val ((m <dis_info>))
|
||||||
|
(roslisp-msg-protocol:msg-deprecation-warning "Using old-style slot reader rknn_yolov5_demo-msg:height-val is deprecated. Use rknn_yolov5_demo-msg:height instead.")
|
||||||
|
(height m))
|
||||||
|
|
||||||
|
(cl:ensure-generic-function 'angle-val :lambda-list '(m))
|
||||||
|
(cl:defmethod angle-val ((m <dis_info>))
|
||||||
|
(roslisp-msg-protocol:msg-deprecation-warning "Using old-style slot reader rknn_yolov5_demo-msg:angle-val is deprecated. Use rknn_yolov5_demo-msg:angle instead.")
|
||||||
|
(angle m))
|
||||||
|
(cl:defmethod roslisp-msg-protocol:serialize ((msg <dis_info>) ostream)
|
||||||
|
"Serializes a message object of type '<dis_info>"
|
||||||
|
(cl:let ((bits (roslisp-utils:encode-single-float-bits (cl:slot-value msg 'distance))))
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 0) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 8) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 16) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 24) bits) ostream))
|
||||||
|
(cl:let ((bits (roslisp-utils:encode-single-float-bits (cl:slot-value msg 'width))))
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 0) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 8) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 16) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 24) bits) ostream))
|
||||||
|
(cl:let ((bits (roslisp-utils:encode-single-float-bits (cl:slot-value msg 'height))))
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 0) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 8) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 16) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 24) bits) ostream))
|
||||||
|
(cl:let ((bits (roslisp-utils:encode-single-float-bits (cl:slot-value msg 'angle))))
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 0) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 8) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 16) bits) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 24) bits) ostream))
|
||||||
|
)
|
||||||
|
(cl:defmethod roslisp-msg-protocol:deserialize ((msg <dis_info>) istream)
|
||||||
|
"Deserializes a message object of type '<dis_info>"
|
||||||
|
(cl:let ((bits 0))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 0) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 8) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 16) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 24) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:slot-value msg 'distance) (roslisp-utils:decode-single-float-bits bits)))
|
||||||
|
(cl:let ((bits 0))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 0) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 8) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 16) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 24) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:slot-value msg 'width) (roslisp-utils:decode-single-float-bits bits)))
|
||||||
|
(cl:let ((bits 0))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 0) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 8) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 16) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 24) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:slot-value msg 'height) (roslisp-utils:decode-single-float-bits bits)))
|
||||||
|
(cl:let ((bits 0))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 0) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 8) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 16) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 24) bits) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:slot-value msg 'angle) (roslisp-utils:decode-single-float-bits bits)))
|
||||||
|
msg
|
||||||
|
)
|
||||||
|
(cl:defmethod roslisp-msg-protocol:ros-datatype ((msg (cl:eql '<dis_info>)))
|
||||||
|
"Returns string type for a message object of type '<dis_info>"
|
||||||
|
"rknn_yolov5_demo/dis_info")
|
||||||
|
(cl:defmethod roslisp-msg-protocol:ros-datatype ((msg (cl:eql 'dis_info)))
|
||||||
|
"Returns string type for a message object of type 'dis_info"
|
||||||
|
"rknn_yolov5_demo/dis_info")
|
||||||
|
(cl:defmethod roslisp-msg-protocol:md5sum ((type (cl:eql '<dis_info>)))
|
||||||
|
"Returns md5sum for a message object of type '<dis_info>"
|
||||||
|
"941a1dedbc0595405760672b9f7f50ee")
|
||||||
|
(cl:defmethod roslisp-msg-protocol:md5sum ((type (cl:eql 'dis_info)))
|
||||||
|
"Returns md5sum for a message object of type 'dis_info"
|
||||||
|
"941a1dedbc0595405760672b9f7f50ee")
|
||||||
|
(cl:defmethod roslisp-msg-protocol:message-definition ((type (cl:eql '<dis_info>)))
|
||||||
|
"Returns full string definition for message of type '<dis_info>"
|
||||||
|
(cl:format cl:nil "float32 distance~%float32 width~%float32 height~%float32 angle~%~%~%"))
|
||||||
|
(cl:defmethod roslisp-msg-protocol:message-definition ((type (cl:eql 'dis_info)))
|
||||||
|
"Returns full string definition for message of type 'dis_info"
|
||||||
|
(cl:format cl:nil "float32 distance~%float32 width~%float32 height~%float32 angle~%~%~%"))
|
||||||
|
(cl:defmethod roslisp-msg-protocol:serialization-length ((msg <dis_info>))
|
||||||
|
(cl:+ 0
|
||||||
|
4
|
||||||
|
4
|
||||||
|
4
|
||||||
|
4
|
||||||
|
))
|
||||||
|
(cl:defmethod roslisp-msg-protocol:ros-message-to-list ((msg <dis_info>))
|
||||||
|
"Converts a ROS message object to a list"
|
||||||
|
(cl:list 'dis_info
|
||||||
|
(cl:cons ':distance (distance msg))
|
||||||
|
(cl:cons ':width (width msg))
|
||||||
|
(cl:cons ':height (height msg))
|
||||||
|
(cl:cons ':angle (angle msg))
|
||||||
|
))
|
|
@ -0,0 +1,79 @@
|
||||||
|
; Auto-generated. Do not edit!
|
||||||
|
|
||||||
|
|
||||||
|
(cl:in-package rknn_yolov5_demo-msg)
|
||||||
|
|
||||||
|
|
||||||
|
;//! \htmlinclude dis_info_array.msg.html
|
||||||
|
|
||||||
|
(cl:defclass <dis_info_array> (roslisp-msg-protocol:ros-message)
|
||||||
|
((dis
|
||||||
|
:reader dis
|
||||||
|
:initarg :dis
|
||||||
|
:type (cl:vector rknn_yolov5_demo-msg:dis_info)
|
||||||
|
:initform (cl:make-array 0 :element-type 'rknn_yolov5_demo-msg:dis_info :initial-element (cl:make-instance 'rknn_yolov5_demo-msg:dis_info))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(cl:defclass dis_info_array (<dis_info_array>)
|
||||||
|
())
|
||||||
|
|
||||||
|
(cl:defmethod cl:initialize-instance :after ((m <dis_info_array>) cl:&rest args)
|
||||||
|
(cl:declare (cl:ignorable args))
|
||||||
|
(cl:unless (cl:typep m 'dis_info_array)
|
||||||
|
(roslisp-msg-protocol:msg-deprecation-warning "using old message class name rknn_yolov5_demo-msg:<dis_info_array> is deprecated: use rknn_yolov5_demo-msg:dis_info_array instead.")))
|
||||||
|
|
||||||
|
(cl:ensure-generic-function 'dis-val :lambda-list '(m))
|
||||||
|
(cl:defmethod dis-val ((m <dis_info_array>))
|
||||||
|
(roslisp-msg-protocol:msg-deprecation-warning "Using old-style slot reader rknn_yolov5_demo-msg:dis-val is deprecated. Use rknn_yolov5_demo-msg:dis instead.")
|
||||||
|
(dis m))
|
||||||
|
(cl:defmethod roslisp-msg-protocol:serialize ((msg <dis_info_array>) ostream)
|
||||||
|
"Serializes a message object of type '<dis_info_array>"
|
||||||
|
(cl:let ((__ros_arr_len (cl:length (cl:slot-value msg 'dis))))
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 0) __ros_arr_len) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 8) __ros_arr_len) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 16) __ros_arr_len) ostream)
|
||||||
|
(cl:write-byte (cl:ldb (cl:byte 8 24) __ros_arr_len) ostream))
|
||||||
|
(cl:map cl:nil #'(cl:lambda (ele) (roslisp-msg-protocol:serialize ele ostream))
|
||||||
|
(cl:slot-value msg 'dis))
|
||||||
|
)
|
||||||
|
(cl:defmethod roslisp-msg-protocol:deserialize ((msg <dis_info_array>) istream)
|
||||||
|
"Deserializes a message object of type '<dis_info_array>"
|
||||||
|
(cl:let ((__ros_arr_len 0))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 0) __ros_arr_len) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 8) __ros_arr_len) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 16) __ros_arr_len) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:ldb (cl:byte 8 24) __ros_arr_len) (cl:read-byte istream))
|
||||||
|
(cl:setf (cl:slot-value msg 'dis) (cl:make-array __ros_arr_len))
|
||||||
|
(cl:let ((vals (cl:slot-value msg 'dis)))
|
||||||
|
(cl:dotimes (i __ros_arr_len)
|
||||||
|
(cl:setf (cl:aref vals i) (cl:make-instance 'rknn_yolov5_demo-msg:dis_info))
|
||||||
|
(roslisp-msg-protocol:deserialize (cl:aref vals i) istream))))
|
||||||
|
msg
|
||||||
|
)
|
||||||
|
(cl:defmethod roslisp-msg-protocol:ros-datatype ((msg (cl:eql '<dis_info_array>)))
|
||||||
|
"Returns string type for a message object of type '<dis_info_array>"
|
||||||
|
"rknn_yolov5_demo/dis_info_array")
|
||||||
|
(cl:defmethod roslisp-msg-protocol:ros-datatype ((msg (cl:eql 'dis_info_array)))
|
||||||
|
"Returns string type for a message object of type 'dis_info_array"
|
||||||
|
"rknn_yolov5_demo/dis_info_array")
|
||||||
|
(cl:defmethod roslisp-msg-protocol:md5sum ((type (cl:eql '<dis_info_array>)))
|
||||||
|
"Returns md5sum for a message object of type '<dis_info_array>"
|
||||||
|
"154c19253095a5ca966c5dce84293342")
|
||||||
|
(cl:defmethod roslisp-msg-protocol:md5sum ((type (cl:eql 'dis_info_array)))
|
||||||
|
"Returns md5sum for a message object of type 'dis_info_array"
|
||||||
|
"154c19253095a5ca966c5dce84293342")
|
||||||
|
(cl:defmethod roslisp-msg-protocol:message-definition ((type (cl:eql '<dis_info_array>)))
|
||||||
|
"Returns full string definition for message of type '<dis_info_array>"
|
||||||
|
(cl:format cl:nil "rknn_yolov5_demo/dis_info[] dis~%================================================================================~%MSG: rknn_yolov5_demo/dis_info~%float32 distance~%float32 width~%float32 height~%float32 angle~%~%~%"))
|
||||||
|
(cl:defmethod roslisp-msg-protocol:message-definition ((type (cl:eql 'dis_info_array)))
|
||||||
|
"Returns full string definition for message of type 'dis_info_array"
|
||||||
|
(cl:format cl:nil "rknn_yolov5_demo/dis_info[] dis~%================================================================================~%MSG: rknn_yolov5_demo/dis_info~%float32 distance~%float32 width~%float32 height~%float32 angle~%~%~%"))
|
||||||
|
(cl:defmethod roslisp-msg-protocol:serialization-length ((msg <dis_info_array>))
|
||||||
|
(cl:+ 0
|
||||||
|
4 (cl:reduce #'cl:+ (cl:slot-value msg 'dis) :key #'(cl:lambda (ele) (cl:declare (cl:ignorable ele)) (cl:+ (roslisp-msg-protocol:serialization-length ele))))
|
||||||
|
))
|
||||||
|
(cl:defmethod roslisp-msg-protocol:ros-message-to-list ((msg <dis_info_array>))
|
||||||
|
"Converts a ROS message object to a list"
|
||||||
|
(cl:list 'dis_info_array
|
||||||
|
(cl:cons ':dis (dis msg))
|
||||||
|
))
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
(cl:in-package :asdf)
|
||||||
|
|
||||||
|
(defsystem "rknn_yolov5_demo-msg"
|
||||||
|
:depends-on (:roslisp-msg-protocol :roslisp-utils )
|
||||||
|
:components ((:file "_package")
|
||||||
|
(:file "dis_info" :depends-on ("_package_dis_info"))
|
||||||
|
(:file "_package_dis_info" :depends-on ("_package"))
|
||||||
|
(:file "dis_info_array" :depends-on ("_package_dis_info_array"))
|
||||||
|
(:file "_package_dis_info_array" :depends-on ("_package"))
|
||||||
|
))
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
msg: require('./msg/_index.js'),
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
let dis_info = require('./dis_info.js');
|
||||||
|
let dis_info_array = require('./dis_info_array.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
dis_info: dis_info,
|
||||||
|
dis_info_array: dis_info_array,
|
||||||
|
};
|
|
@ -0,0 +1,145 @@
|
||||||
|
// Auto-generated. Do not edit!
|
||||||
|
|
||||||
|
// (in-package rknn_yolov5_demo.msg)
|
||||||
|
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const _serializer = _ros_msg_utils.Serialize;
|
||||||
|
const _arraySerializer = _serializer.Array;
|
||||||
|
const _deserializer = _ros_msg_utils.Deserialize;
|
||||||
|
const _arrayDeserializer = _deserializer.Array;
|
||||||
|
const _finder = _ros_msg_utils.Find;
|
||||||
|
const _getByteLength = _ros_msg_utils.getByteLength;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
class dis_info {
|
||||||
|
constructor(initObj={}) {
|
||||||
|
if (initObj === null) {
|
||||||
|
// initObj === null is a special case for deserialization where we don't initialize fields
|
||||||
|
this.distance = null;
|
||||||
|
this.width = null;
|
||||||
|
this.height = null;
|
||||||
|
this.angle = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (initObj.hasOwnProperty('distance')) {
|
||||||
|
this.distance = initObj.distance
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.distance = 0.0;
|
||||||
|
}
|
||||||
|
if (initObj.hasOwnProperty('width')) {
|
||||||
|
this.width = initObj.width
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.width = 0.0;
|
||||||
|
}
|
||||||
|
if (initObj.hasOwnProperty('height')) {
|
||||||
|
this.height = initObj.height
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.height = 0.0;
|
||||||
|
}
|
||||||
|
if (initObj.hasOwnProperty('angle')) {
|
||||||
|
this.angle = initObj.angle
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.angle = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static serialize(obj, buffer, bufferOffset) {
|
||||||
|
// Serializes a message object of type dis_info
|
||||||
|
// Serialize message field [distance]
|
||||||
|
bufferOffset = _serializer.float32(obj.distance, buffer, bufferOffset);
|
||||||
|
// Serialize message field [width]
|
||||||
|
bufferOffset = _serializer.float32(obj.width, buffer, bufferOffset);
|
||||||
|
// Serialize message field [height]
|
||||||
|
bufferOffset = _serializer.float32(obj.height, buffer, bufferOffset);
|
||||||
|
// Serialize message field [angle]
|
||||||
|
bufferOffset = _serializer.float32(obj.angle, buffer, bufferOffset);
|
||||||
|
return bufferOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
static deserialize(buffer, bufferOffset=[0]) {
|
||||||
|
//deserializes a message object of type dis_info
|
||||||
|
let len;
|
||||||
|
let data = new dis_info(null);
|
||||||
|
// Deserialize message field [distance]
|
||||||
|
data.distance = _deserializer.float32(buffer, bufferOffset);
|
||||||
|
// Deserialize message field [width]
|
||||||
|
data.width = _deserializer.float32(buffer, bufferOffset);
|
||||||
|
// Deserialize message field [height]
|
||||||
|
data.height = _deserializer.float32(buffer, bufferOffset);
|
||||||
|
// Deserialize message field [angle]
|
||||||
|
data.angle = _deserializer.float32(buffer, bufferOffset);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getMessageSize(object) {
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
static datatype() {
|
||||||
|
// Returns string type for a message object
|
||||||
|
return 'rknn_yolov5_demo/dis_info';
|
||||||
|
}
|
||||||
|
|
||||||
|
static md5sum() {
|
||||||
|
//Returns md5sum for a message object
|
||||||
|
return '941a1dedbc0595405760672b9f7f50ee';
|
||||||
|
}
|
||||||
|
|
||||||
|
static messageDefinition() {
|
||||||
|
// Returns full string definition for message
|
||||||
|
return `
|
||||||
|
float32 distance
|
||||||
|
float32 width
|
||||||
|
float32 height
|
||||||
|
float32 angle
|
||||||
|
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Resolve(msg) {
|
||||||
|
// deep-construct a valid message object instance of whatever was passed in
|
||||||
|
if (typeof msg !== 'object' || msg === null) {
|
||||||
|
msg = {};
|
||||||
|
}
|
||||||
|
const resolved = new dis_info(null);
|
||||||
|
if (msg.distance !== undefined) {
|
||||||
|
resolved.distance = msg.distance;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolved.distance = 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.width !== undefined) {
|
||||||
|
resolved.width = msg.width;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolved.width = 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.height !== undefined) {
|
||||||
|
resolved.height = msg.height;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolved.height = 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.angle !== undefined) {
|
||||||
|
resolved.angle = msg.angle;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolved.angle = 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolved;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = dis_info;
|
|
@ -0,0 +1,109 @@
|
||||||
|
// Auto-generated. Do not edit!
|
||||||
|
|
||||||
|
// (in-package rknn_yolov5_demo.msg)
|
||||||
|
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const _serializer = _ros_msg_utils.Serialize;
|
||||||
|
const _arraySerializer = _serializer.Array;
|
||||||
|
const _deserializer = _ros_msg_utils.Deserialize;
|
||||||
|
const _arrayDeserializer = _deserializer.Array;
|
||||||
|
const _finder = _ros_msg_utils.Find;
|
||||||
|
const _getByteLength = _ros_msg_utils.getByteLength;
|
||||||
|
let dis_info = require('./dis_info.js');
|
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
class dis_info_array {
|
||||||
|
constructor(initObj={}) {
|
||||||
|
if (initObj === null) {
|
||||||
|
// initObj === null is a special case for deserialization where we don't initialize fields
|
||||||
|
this.dis = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (initObj.hasOwnProperty('dis')) {
|
||||||
|
this.dis = initObj.dis
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dis = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static serialize(obj, buffer, bufferOffset) {
|
||||||
|
// Serializes a message object of type dis_info_array
|
||||||
|
// Serialize message field [dis]
|
||||||
|
// Serialize the length for message field [dis]
|
||||||
|
bufferOffset = _serializer.uint32(obj.dis.length, buffer, bufferOffset);
|
||||||
|
obj.dis.forEach((val) => {
|
||||||
|
bufferOffset = dis_info.serialize(val, buffer, bufferOffset);
|
||||||
|
});
|
||||||
|
return bufferOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
static deserialize(buffer, bufferOffset=[0]) {
|
||||||
|
//deserializes a message object of type dis_info_array
|
||||||
|
let len;
|
||||||
|
let data = new dis_info_array(null);
|
||||||
|
// Deserialize message field [dis]
|
||||||
|
// Deserialize array length for message field [dis]
|
||||||
|
len = _deserializer.uint32(buffer, bufferOffset);
|
||||||
|
data.dis = new Array(len);
|
||||||
|
for (let i = 0; i < len; ++i) {
|
||||||
|
data.dis[i] = dis_info.deserialize(buffer, bufferOffset)
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getMessageSize(object) {
|
||||||
|
let length = 0;
|
||||||
|
length += 16 * object.dis.length;
|
||||||
|
return length + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
static datatype() {
|
||||||
|
// Returns string type for a message object
|
||||||
|
return 'rknn_yolov5_demo/dis_info_array';
|
||||||
|
}
|
||||||
|
|
||||||
|
static md5sum() {
|
||||||
|
//Returns md5sum for a message object
|
||||||
|
return '154c19253095a5ca966c5dce84293342';
|
||||||
|
}
|
||||||
|
|
||||||
|
static messageDefinition() {
|
||||||
|
// Returns full string definition for message
|
||||||
|
return `
|
||||||
|
rknn_yolov5_demo/dis_info[] dis
|
||||||
|
================================================================================
|
||||||
|
MSG: rknn_yolov5_demo/dis_info
|
||||||
|
float32 distance
|
||||||
|
float32 width
|
||||||
|
float32 height
|
||||||
|
float32 angle
|
||||||
|
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Resolve(msg) {
|
||||||
|
// deep-construct a valid message object instance of whatever was passed in
|
||||||
|
if (typeof msg !== 'object' || msg === null) {
|
||||||
|
msg = {};
|
||||||
|
}
|
||||||
|
const resolved = new dis_info_array(null);
|
||||||
|
if (msg.dis !== undefined) {
|
||||||
|
resolved.dis = new Array(msg.dis.length);
|
||||||
|
for (let i = 0; i < resolved.dis.length; ++i) {
|
||||||
|
resolved.dis[i] = dis_info.Resolve(msg.dis[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolved.dis = []
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolved;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = dis_info_array;
|
|
@ -0,0 +1,2 @@
|
||||||
|
set(rknn_yolov5_demo_MESSAGE_FILES "/home/firefly/obj_dec/src/rknn_yolov5_demo/msg/dis_info.msg;/home/firefly/obj_dec/src/rknn_yolov5_demo/msg/dis_info_array.msg")
|
||||||
|
set(rknn_yolov5_demo_SERVICE_FILES "")
|
|
@ -0,0 +1,4 @@
|
||||||
|
# generated from genmsg/cmake/pkg-msg-paths.cmake.develspace.in
|
||||||
|
|
||||||
|
set(rknn_yolov5_demo_MSG_INCLUDE_DIRS "/home/firefly/obj_dec/src/rknn_yolov5_demo/msg")
|
||||||
|
set(rknn_yolov5_demo_MSG_DEPENDENCIES std_msgs)
|
|
@ -0,0 +1,14 @@
|
||||||
|
# generated from catkin/cmake/template/pkgConfig-version.cmake.in
|
||||||
|
set(PACKAGE_VERSION "0.0.0")
|
||||||
|
|
||||||
|
set(PACKAGE_VERSION_EXACT False)
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE False)
|
||||||
|
|
||||||
|
if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}")
|
||||||
|
set(PACKAGE_VERSION_EXACT True)
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE True)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${PACKAGE_FIND_VERSION}" VERSION_LESS "${PACKAGE_VERSION}")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE True)
|
||||||
|
endif()
|
|
@ -0,0 +1,223 @@
|
||||||
|
# generated from catkin/cmake/template/pkgConfig.cmake.in
|
||||||
|
|
||||||
|
# append elements to a list and remove existing duplicates from the list
|
||||||
|
# copied from catkin/cmake/list_append_deduplicate.cmake to keep pkgConfig
|
||||||
|
# self contained
|
||||||
|
macro(_list_append_deduplicate listname)
|
||||||
|
if(NOT "${ARGN}" STREQUAL "")
|
||||||
|
if(${listname})
|
||||||
|
list(REMOVE_ITEM ${listname} ${ARGN})
|
||||||
|
endif()
|
||||||
|
list(APPEND ${listname} ${ARGN})
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# append elements to a list if they are not already in the list
|
||||||
|
# copied from catkin/cmake/list_append_unique.cmake to keep pkgConfig
|
||||||
|
# self contained
|
||||||
|
macro(_list_append_unique listname)
|
||||||
|
foreach(_item ${ARGN})
|
||||||
|
list(FIND ${listname} ${_item} _index)
|
||||||
|
if(_index EQUAL -1)
|
||||||
|
list(APPEND ${listname} ${_item})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# pack a list of libraries with optional build configuration keywords
|
||||||
|
# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
|
||||||
|
# self contained
|
||||||
|
macro(_pack_libraries_with_build_configuration VAR)
|
||||||
|
set(${VAR} "")
|
||||||
|
set(_argn ${ARGN})
|
||||||
|
list(LENGTH _argn _count)
|
||||||
|
set(_index 0)
|
||||||
|
while(${_index} LESS ${_count})
|
||||||
|
list(GET _argn ${_index} lib)
|
||||||
|
if("${lib}" MATCHES "^(debug|optimized|general)$")
|
||||||
|
math(EXPR _index "${_index} + 1")
|
||||||
|
if(${_index} EQUAL ${_count})
|
||||||
|
message(FATAL_ERROR "_pack_libraries_with_build_configuration() the list of libraries '${ARGN}' ends with '${lib}' which is a build configuration keyword and must be followed by a library")
|
||||||
|
endif()
|
||||||
|
list(GET _argn ${_index} library)
|
||||||
|
list(APPEND ${VAR} "${lib}${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}${library}")
|
||||||
|
else()
|
||||||
|
list(APPEND ${VAR} "${lib}")
|
||||||
|
endif()
|
||||||
|
math(EXPR _index "${_index} + 1")
|
||||||
|
endwhile()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# unpack a list of libraries with optional build configuration keyword prefixes
|
||||||
|
# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
|
||||||
|
# self contained
|
||||||
|
macro(_unpack_libraries_with_build_configuration VAR)
|
||||||
|
set(${VAR} "")
|
||||||
|
foreach(lib ${ARGN})
|
||||||
|
string(REGEX REPLACE "^(debug|optimized|general)${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}(.+)$" "\\1;\\2" lib "${lib}")
|
||||||
|
list(APPEND ${VAR} "${lib}")
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
if(rknn_yolov5_demo_CONFIG_INCLUDED)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(rknn_yolov5_demo_CONFIG_INCLUDED TRUE)
|
||||||
|
|
||||||
|
# set variables for source/devel/install prefixes
|
||||||
|
if("TRUE" STREQUAL "TRUE")
|
||||||
|
set(rknn_yolov5_demo_SOURCE_PREFIX /home/firefly/obj_dec/src/rknn_yolov5_demo)
|
||||||
|
set(rknn_yolov5_demo_DEVEL_PREFIX /home/firefly/obj_dec/devel)
|
||||||
|
set(rknn_yolov5_demo_INSTALL_PREFIX "")
|
||||||
|
set(rknn_yolov5_demo_PREFIX ${rknn_yolov5_demo_DEVEL_PREFIX})
|
||||||
|
else()
|
||||||
|
set(rknn_yolov5_demo_SOURCE_PREFIX "")
|
||||||
|
set(rknn_yolov5_demo_DEVEL_PREFIX "")
|
||||||
|
set(rknn_yolov5_demo_INSTALL_PREFIX /home/firefly/obj_dec/install)
|
||||||
|
set(rknn_yolov5_demo_PREFIX ${rknn_yolov5_demo_INSTALL_PREFIX})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# warn when using a deprecated package
|
||||||
|
if(NOT "" STREQUAL "")
|
||||||
|
set(_msg "WARNING: package 'rknn_yolov5_demo' is deprecated")
|
||||||
|
# append custom deprecation text if available
|
||||||
|
if(NOT "" STREQUAL "TRUE")
|
||||||
|
set(_msg "${_msg} ()")
|
||||||
|
endif()
|
||||||
|
message("${_msg}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# flag project as catkin-based to distinguish if a find_package()-ed project is a catkin project
|
||||||
|
set(rknn_yolov5_demo_FOUND_CATKIN_PROJECT TRUE)
|
||||||
|
|
||||||
|
if(NOT "/home/firefly/obj_dec/devel/include " STREQUAL " ")
|
||||||
|
set(rknn_yolov5_demo_INCLUDE_DIRS "")
|
||||||
|
set(_include_dirs "/home/firefly/obj_dec/devel/include")
|
||||||
|
if(NOT " " STREQUAL " ")
|
||||||
|
set(_report "Check the issue tracker '' and consider creating a ticket if the problem has not been reported yet.")
|
||||||
|
elseif(NOT " " STREQUAL " ")
|
||||||
|
set(_report "Check the website '' for information and consider reporting the problem.")
|
||||||
|
else()
|
||||||
|
set(_report "Report the problem to the maintainer 'firefly <firefly@todo.todo>' and request to fix the problem.")
|
||||||
|
endif()
|
||||||
|
foreach(idir ${_include_dirs})
|
||||||
|
if(IS_ABSOLUTE ${idir} AND IS_DIRECTORY ${idir})
|
||||||
|
set(include ${idir})
|
||||||
|
elseif("${idir} " STREQUAL "include ")
|
||||||
|
get_filename_component(include "${rknn_yolov5_demo_DIR}/../../../include" ABSOLUTE)
|
||||||
|
if(NOT IS_DIRECTORY ${include})
|
||||||
|
message(FATAL_ERROR "Project 'rknn_yolov5_demo' specifies '${idir}' as an include dir, which is not found. It does not exist in '${include}'. ${_report}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Project 'rknn_yolov5_demo' specifies '${idir}' as an include dir, which is not found. It does neither exist as an absolute directory nor in '/home/firefly/obj_dec/src/rknn_yolov5_demo/${idir}'. ${_report}")
|
||||||
|
endif()
|
||||||
|
_list_append_unique(rknn_yolov5_demo_INCLUDE_DIRS ${include})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(libraries "")
|
||||||
|
foreach(library ${libraries})
|
||||||
|
# keep build configuration keywords, target names and absolute libraries as-is
|
||||||
|
if("${library}" MATCHES "^(debug|optimized|general)$")
|
||||||
|
list(APPEND rknn_yolov5_demo_LIBRARIES ${library})
|
||||||
|
elseif(${library} MATCHES "^-l")
|
||||||
|
list(APPEND rknn_yolov5_demo_LIBRARIES ${library})
|
||||||
|
elseif(${library} MATCHES "^-")
|
||||||
|
# This is a linker flag/option (like -pthread)
|
||||||
|
# There's no standard variable for these, so create an interface library to hold it
|
||||||
|
if(NOT rknn_yolov5_demo_NUM_DUMMY_TARGETS)
|
||||||
|
set(rknn_yolov5_demo_NUM_DUMMY_TARGETS 0)
|
||||||
|
endif()
|
||||||
|
# Make sure the target name is unique
|
||||||
|
set(interface_target_name "catkin::rknn_yolov5_demo::wrapped-linker-option${rknn_yolov5_demo_NUM_DUMMY_TARGETS}")
|
||||||
|
while(TARGET "${interface_target_name}")
|
||||||
|
math(EXPR rknn_yolov5_demo_NUM_DUMMY_TARGETS "${rknn_yolov5_demo_NUM_DUMMY_TARGETS}+1")
|
||||||
|
set(interface_target_name "catkin::rknn_yolov5_demo::wrapped-linker-option${rknn_yolov5_demo_NUM_DUMMY_TARGETS}")
|
||||||
|
endwhile()
|
||||||
|
add_library("${interface_target_name}" INTERFACE IMPORTED)
|
||||||
|
if("${CMAKE_VERSION}" VERSION_LESS "3.13.0")
|
||||||
|
set_property(
|
||||||
|
TARGET
|
||||||
|
"${interface_target_name}"
|
||||||
|
APPEND PROPERTY
|
||||||
|
INTERFACE_LINK_LIBRARIES "${library}")
|
||||||
|
else()
|
||||||
|
target_link_options("${interface_target_name}" INTERFACE "${library}")
|
||||||
|
endif()
|
||||||
|
list(APPEND rknn_yolov5_demo_LIBRARIES "${interface_target_name}")
|
||||||
|
elseif(TARGET ${library})
|
||||||
|
list(APPEND rknn_yolov5_demo_LIBRARIES ${library})
|
||||||
|
elseif(IS_ABSOLUTE ${library})
|
||||||
|
list(APPEND rknn_yolov5_demo_LIBRARIES ${library})
|
||||||
|
else()
|
||||||
|
set(lib_path "")
|
||||||
|
set(lib "${library}-NOTFOUND")
|
||||||
|
# since the path where the library is found is returned we have to iterate over the paths manually
|
||||||
|
foreach(path /home/firefly/obj_dec/devel/lib;/home/firefly/obj_dec/devel/lib;/home/firefly/pibot_ros/ros_ws/devel/lib;/opt/ros/noetic/lib)
|
||||||
|
find_library(lib ${library}
|
||||||
|
PATHS ${path}
|
||||||
|
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
||||||
|
if(lib)
|
||||||
|
set(lib_path ${path})
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if(lib)
|
||||||
|
_list_append_unique(rknn_yolov5_demo_LIBRARY_DIRS ${lib_path})
|
||||||
|
list(APPEND rknn_yolov5_demo_LIBRARIES ${lib})
|
||||||
|
else()
|
||||||
|
# as a fall back for non-catkin libraries try to search globally
|
||||||
|
find_library(lib ${library})
|
||||||
|
if(NOT lib)
|
||||||
|
message(FATAL_ERROR "Project '${PROJECT_NAME}' tried to find library '${library}'. The library is neither a target nor built/installed properly. Did you compile project 'rknn_yolov5_demo'? Did you find_package() it before the subdirectory containing its code is included?")
|
||||||
|
endif()
|
||||||
|
list(APPEND rknn_yolov5_demo_LIBRARIES ${lib})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(rknn_yolov5_demo_EXPORTED_TARGETS "rknn_yolov5_demo_generate_messages_cpp;rknn_yolov5_demo_generate_messages_eus;rknn_yolov5_demo_generate_messages_lisp;rknn_yolov5_demo_generate_messages_nodejs;rknn_yolov5_demo_generate_messages_py")
|
||||||
|
# create dummy targets for exported code generation targets to make life of users easier
|
||||||
|
foreach(t ${rknn_yolov5_demo_EXPORTED_TARGETS})
|
||||||
|
if(NOT TARGET ${t})
|
||||||
|
add_custom_target(${t})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(depends "roscpp;std_msgs;message_runtime")
|
||||||
|
foreach(depend ${depends})
|
||||||
|
string(REPLACE " " ";" depend_list ${depend})
|
||||||
|
# the package name of the dependency must be kept in a unique variable so that it is not overwritten in recursive calls
|
||||||
|
list(GET depend_list 0 rknn_yolov5_demo_dep)
|
||||||
|
list(LENGTH depend_list count)
|
||||||
|
if(${count} EQUAL 1)
|
||||||
|
# simple dependencies must only be find_package()-ed once
|
||||||
|
if(NOT ${rknn_yolov5_demo_dep}_FOUND)
|
||||||
|
find_package(${rknn_yolov5_demo_dep} REQUIRED NO_MODULE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# dependencies with components must be find_package()-ed again
|
||||||
|
list(REMOVE_AT depend_list 0)
|
||||||
|
find_package(${rknn_yolov5_demo_dep} REQUIRED NO_MODULE ${depend_list})
|
||||||
|
endif()
|
||||||
|
_list_append_unique(rknn_yolov5_demo_INCLUDE_DIRS ${${rknn_yolov5_demo_dep}_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
# merge build configuration keywords with library names to correctly deduplicate
|
||||||
|
_pack_libraries_with_build_configuration(rknn_yolov5_demo_LIBRARIES ${rknn_yolov5_demo_LIBRARIES})
|
||||||
|
_pack_libraries_with_build_configuration(_libraries ${${rknn_yolov5_demo_dep}_LIBRARIES})
|
||||||
|
_list_append_deduplicate(rknn_yolov5_demo_LIBRARIES ${_libraries})
|
||||||
|
# undo build configuration keyword merging after deduplication
|
||||||
|
_unpack_libraries_with_build_configuration(rknn_yolov5_demo_LIBRARIES ${rknn_yolov5_demo_LIBRARIES})
|
||||||
|
|
||||||
|
_list_append_unique(rknn_yolov5_demo_LIBRARY_DIRS ${${rknn_yolov5_demo_dep}_LIBRARY_DIRS})
|
||||||
|
_list_append_deduplicate(rknn_yolov5_demo_EXPORTED_TARGETS ${${rknn_yolov5_demo_dep}_EXPORTED_TARGETS})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(pkg_cfg_extras "rknn_yolov5_demo-msg-extras.cmake")
|
||||||
|
foreach(extra ${pkg_cfg_extras})
|
||||||
|
if(NOT IS_ABSOLUTE ${extra})
|
||||||
|
set(extra ${rknn_yolov5_demo_DIR}/${extra})
|
||||||
|
endif()
|
||||||
|
include(${extra})
|
||||||
|
endforeach()
|
|
@ -0,0 +1,11 @@
|
||||||
|
;;
|
||||||
|
;; DO NOT EDIT THIS FILE
|
||||||
|
;;
|
||||||
|
;; THIS FILE IS AUTOMATICALLY GENERATED
|
||||||
|
;; FROM /home/firefly/obj_dec/src/rknn_yolov5_demo/package.xml (0.0.0)
|
||||||
|
;; USING /opt/ros/noetic/lib/python3/dist-packages/geneus/geneus_main.py /opt/ros/noetic/share/geneus/package.xml (3.0.0)
|
||||||
|
;;
|
||||||
|
(ros::load-ros-package "roscpp")
|
||||||
|
(ros::load-ros-package "rosgraph_msgs")
|
||||||
|
(ros::load-ros-package "std_msgs")
|
||||||
|
(ros::load-ros-package "rknn_yolov5_demo")
|
|
@ -0,0 +1,99 @@
|
||||||
|
;; Auto-generated. Do not edit!
|
||||||
|
|
||||||
|
|
||||||
|
(when (boundp 'rknn_yolov5_demo::dis_info)
|
||||||
|
(if (not (find-package "RKNN_YOLOV5_DEMO"))
|
||||||
|
(make-package "RKNN_YOLOV5_DEMO"))
|
||||||
|
(shadow 'dis_info (find-package "RKNN_YOLOV5_DEMO")))
|
||||||
|
(unless (find-package "RKNN_YOLOV5_DEMO::DIS_INFO")
|
||||||
|
(make-package "RKNN_YOLOV5_DEMO::DIS_INFO"))
|
||||||
|
|
||||||
|
(in-package "ROS")
|
||||||
|
;;//! \htmlinclude dis_info.msg.html
|
||||||
|
|
||||||
|
|
||||||
|
(defclass rknn_yolov5_demo::dis_info
|
||||||
|
:super ros::object
|
||||||
|
:slots (_distance _width _height _angle ))
|
||||||
|
|
||||||
|
(defmethod rknn_yolov5_demo::dis_info
|
||||||
|
(:init
|
||||||
|
(&key
|
||||||
|
((:distance __distance) 0.0)
|
||||||
|
((:width __width) 0.0)
|
||||||
|
((:height __height) 0.0)
|
||||||
|
((:angle __angle) 0.0)
|
||||||
|
)
|
||||||
|
(send-super :init)
|
||||||
|
(setq _distance (float __distance))
|
||||||
|
(setq _width (float __width))
|
||||||
|
(setq _height (float __height))
|
||||||
|
(setq _angle (float __angle))
|
||||||
|
self)
|
||||||
|
(:distance
|
||||||
|
(&optional __distance)
|
||||||
|
(if __distance (setq _distance __distance)) _distance)
|
||||||
|
(:width
|
||||||
|
(&optional __width)
|
||||||
|
(if __width (setq _width __width)) _width)
|
||||||
|
(:height
|
||||||
|
(&optional __height)
|
||||||
|
(if __height (setq _height __height)) _height)
|
||||||
|
(:angle
|
||||||
|
(&optional __angle)
|
||||||
|
(if __angle (setq _angle __angle)) _angle)
|
||||||
|
(:serialization-length
|
||||||
|
()
|
||||||
|
(+
|
||||||
|
;; float32 _distance
|
||||||
|
4
|
||||||
|
;; float32 _width
|
||||||
|
4
|
||||||
|
;; float32 _height
|
||||||
|
4
|
||||||
|
;; float32 _angle
|
||||||
|
4
|
||||||
|
))
|
||||||
|
(:serialize
|
||||||
|
(&optional strm)
|
||||||
|
(let ((s (if strm strm
|
||||||
|
(make-string-output-stream (send self :serialization-length)))))
|
||||||
|
;; float32 _distance
|
||||||
|
(sys::poke _distance (send s :buffer) (send s :count) :float) (incf (stream-count s) 4)
|
||||||
|
;; float32 _width
|
||||||
|
(sys::poke _width (send s :buffer) (send s :count) :float) (incf (stream-count s) 4)
|
||||||
|
;; float32 _height
|
||||||
|
(sys::poke _height (send s :buffer) (send s :count) :float) (incf (stream-count s) 4)
|
||||||
|
;; float32 _angle
|
||||||
|
(sys::poke _angle (send s :buffer) (send s :count) :float) (incf (stream-count s) 4)
|
||||||
|
;;
|
||||||
|
(if (null strm) (get-output-stream-string s))))
|
||||||
|
(:deserialize
|
||||||
|
(buf &optional (ptr- 0))
|
||||||
|
;; float32 _distance
|
||||||
|
(setq _distance (sys::peek buf ptr- :float)) (incf ptr- 4)
|
||||||
|
;; float32 _width
|
||||||
|
(setq _width (sys::peek buf ptr- :float)) (incf ptr- 4)
|
||||||
|
;; float32 _height
|
||||||
|
(setq _height (sys::peek buf ptr- :float)) (incf ptr- 4)
|
||||||
|
;; float32 _angle
|
||||||
|
(setq _angle (sys::peek buf ptr- :float)) (incf ptr- 4)
|
||||||
|
;;
|
||||||
|
self)
|
||||||
|
)
|
||||||
|
|
||||||
|
(setf (get rknn_yolov5_demo::dis_info :md5sum-) "941a1dedbc0595405760672b9f7f50ee")
|
||||||
|
(setf (get rknn_yolov5_demo::dis_info :datatype-) "rknn_yolov5_demo/dis_info")
|
||||||
|
(setf (get rknn_yolov5_demo::dis_info :definition-)
|
||||||
|
"float32 distance
|
||||||
|
float32 width
|
||||||
|
float32 height
|
||||||
|
float32 angle
|
||||||
|
|
||||||
|
")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(provide :rknn_yolov5_demo/dis_info "941a1dedbc0595405760672b9f7f50ee")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
;; Auto-generated. Do not edit!
|
||||||
|
|
||||||
|
|
||||||
|
(when (boundp 'rknn_yolov5_demo::dis_info_array)
|
||||||
|
(if (not (find-package "RKNN_YOLOV5_DEMO"))
|
||||||
|
(make-package "RKNN_YOLOV5_DEMO"))
|
||||||
|
(shadow 'dis_info_array (find-package "RKNN_YOLOV5_DEMO")))
|
||||||
|
(unless (find-package "RKNN_YOLOV5_DEMO::DIS_INFO_ARRAY")
|
||||||
|
(make-package "RKNN_YOLOV5_DEMO::DIS_INFO_ARRAY"))
|
||||||
|
|
||||||
|
(in-package "ROS")
|
||||||
|
;;//! \htmlinclude dis_info_array.msg.html
|
||||||
|
|
||||||
|
|
||||||
|
(defclass rknn_yolov5_demo::dis_info_array
|
||||||
|
:super ros::object
|
||||||
|
:slots (_dis ))
|
||||||
|
|
||||||
|
(defmethod rknn_yolov5_demo::dis_info_array
|
||||||
|
(:init
|
||||||
|
(&key
|
||||||
|
((:dis __dis) ())
|
||||||
|
)
|
||||||
|
(send-super :init)
|
||||||
|
(setq _dis __dis)
|
||||||
|
self)
|
||||||
|
(:dis
|
||||||
|
(&rest __dis)
|
||||||
|
(if (keywordp (car __dis))
|
||||||
|
(send* _dis __dis)
|
||||||
|
(progn
|
||||||
|
(if __dis (setq _dis (car __dis)))
|
||||||
|
_dis)))
|
||||||
|
(:serialization-length
|
||||||
|
()
|
||||||
|
(+
|
||||||
|
;; rknn_yolov5_demo/dis_info[] _dis
|
||||||
|
(apply #'+ (send-all _dis :serialization-length)) 4
|
||||||
|
))
|
||||||
|
(:serialize
|
||||||
|
(&optional strm)
|
||||||
|
(let ((s (if strm strm
|
||||||
|
(make-string-output-stream (send self :serialization-length)))))
|
||||||
|
;; rknn_yolov5_demo/dis_info[] _dis
|
||||||
|
(write-long (length _dis) s)
|
||||||
|
(dolist (elem _dis)
|
||||||
|
(send elem :serialize s)
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
(if (null strm) (get-output-stream-string s))))
|
||||||
|
(:deserialize
|
||||||
|
(buf &optional (ptr- 0))
|
||||||
|
;; rknn_yolov5_demo/dis_info[] _dis
|
||||||
|
(let (n)
|
||||||
|
(setq n (sys::peek buf ptr- :integer)) (incf ptr- 4)
|
||||||
|
(setq _dis (let (r) (dotimes (i n) (push (instance rknn_yolov5_demo::dis_info :init) r)) r))
|
||||||
|
(dolist (elem- _dis)
|
||||||
|
(send elem- :deserialize buf ptr-) (incf ptr- (send elem- :serialization-length))
|
||||||
|
))
|
||||||
|
;;
|
||||||
|
self)
|
||||||
|
)
|
||||||
|
|
||||||
|
(setf (get rknn_yolov5_demo::dis_info_array :md5sum-) "154c19253095a5ca966c5dce84293342")
|
||||||
|
(setf (get rknn_yolov5_demo::dis_info_array :datatype-) "rknn_yolov5_demo/dis_info_array")
|
||||||
|
(setf (get rknn_yolov5_demo::dis_info_array :definition-)
|
||||||
|
"rknn_yolov5_demo/dis_info[] dis
|
||||||
|
================================================================================
|
||||||
|
MSG: rknn_yolov5_demo/dis_info
|
||||||
|
float32 distance
|
||||||
|
float32 width
|
||||||
|
float32 height
|
||||||
|
float32 angle
|
||||||
|
|
||||||
|
")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(provide :rknn_yolov5_demo/dis_info_array "154c19253095a5ca966c5dce84293342")
|
||||||
|
|
||||||
|
|
59
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/GrallocOps.h
vendored
Normal file
59
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/GrallocOps.h
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Zhiqin Wei <wzq@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _rk_graphic_buffer_h_
|
||||||
|
#define _rk_graphic_buffer_h_
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <system/graphics.h>
|
||||||
|
|
||||||
|
#include <utils/Thread.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <linux/stddef.h>
|
||||||
|
|
||||||
|
#include <utils/Atomic.h>
|
||||||
|
#include <utils/Errors.h>
|
||||||
|
#include <android/log.h>
|
||||||
|
#include <utils/Log.h>
|
||||||
|
#include <log/log_main.h>
|
||||||
|
|
||||||
|
#include "drmrga.h"
|
||||||
|
#include "rga.h"
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------
|
||||||
|
int RkRgaGetHandleFd(buffer_handle_t handle, int *fd);
|
||||||
|
int RkRgaGetHandleAttributes(buffer_handle_t handle,
|
||||||
|
std::vector<int> *attrs);
|
||||||
|
int RkRgaGetHandleMapAddress(buffer_handle_t handle,
|
||||||
|
void **buf);
|
||||||
|
#endif //Android
|
||||||
|
|
||||||
|
#endif //_rk_graphic_buffer_h_
|
81
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RgaApi.h
vendored
Normal file
81
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RgaApi.h
vendored
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Zhiqin Wei <wzq@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _rockchip_rga_c_h_
|
||||||
|
#define _rockchip_rga_c_h_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <linux/stddef.h>
|
||||||
|
|
||||||
|
#include "drmrga.h"
|
||||||
|
#include "rga.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compatible with the old version of C interface.The new
|
||||||
|
* version of the C interface no longer requires users to
|
||||||
|
* initialize rga, so RgaInit and RgaDeInit are just for
|
||||||
|
* compatibility with the old C interface, so please do
|
||||||
|
* not use ctx, because it is usually a NULL.
|
||||||
|
*/
|
||||||
|
#define RgaInit(ctx) ({ \
|
||||||
|
int ret = 0; \
|
||||||
|
ret = c_RkRgaInit(); \
|
||||||
|
c_RkRgaGetContext(ctx); \
|
||||||
|
ret;\
|
||||||
|
})
|
||||||
|
#define RgaDeInit(ctx) { \
|
||||||
|
(void)ctx; /* unused */ \
|
||||||
|
c_RkRgaDeInit(); \
|
||||||
|
}
|
||||||
|
#define RgaBlit(...) c_RkRgaBlit(__VA_ARGS__)
|
||||||
|
#define RgaCollorFill(...) c_RkRgaColorFill(__VA_ARGS__)
|
||||||
|
#define RgaFlush() c_RkRgaFlush()
|
||||||
|
|
||||||
|
int c_RkRgaInit();
|
||||||
|
void c_RkRgaDeInit();
|
||||||
|
void c_RkRgaGetContext(void **ctx);
|
||||||
|
int c_RkRgaBlit(rga_info_t *src, rga_info_t *dst, rga_info_t *src1);
|
||||||
|
int c_RkRgaColorFill(rga_info_t *dst);
|
||||||
|
int c_RkRgaFlush();
|
||||||
|
|
||||||
|
#ifndef ANDROID /* linux */
|
||||||
|
int c_RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||||
|
int c_RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
|
||||||
|
int c_RkRgaGetMmap(bo_t *bo_info);
|
||||||
|
int c_RkRgaUnmap(bo_t *bo_info);
|
||||||
|
int c_RkRgaFree(bo_t *bo_info);
|
||||||
|
int c_RkRgaGetBufferFd(bo_t *bo_info, int *fd);
|
||||||
|
#endif /* #ifndef ANDROID */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* #ifndef _rockchip_rga_c_h_ */
|
193
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RgaMutex.h
vendored
Normal file
193
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RgaMutex.h
vendored
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* PutinLee <putin.lee@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _LIBS_RGA_MUTEX_H
|
||||||
|
#define _LIBS_RGA_MUTEX_H
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Enable thread safety attributes only with clang.
|
||||||
|
// The attributes can be safely erased when compiling with other compilers.
|
||||||
|
#if defined(__clang__) && (!defined(SWIG))
|
||||||
|
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
|
||||||
|
#else
|
||||||
|
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
|
||||||
|
|
||||||
|
#define SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
|
||||||
|
|
||||||
|
#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
|
||||||
|
|
||||||
|
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
|
||||||
|
|
||||||
|
#define ACQUIRED_BEFORE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define ACQUIRED_AFTER(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define REQUIRES(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define REQUIRES_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define ACQUIRE_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define RELEASE(...) THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define RELEASE_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define TRY_ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define TRY_ACQUIRE_SHARED(...) \
|
||||||
|
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
|
||||||
|
|
||||||
|
#define ASSERT_SHARED_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
|
||||||
|
|
||||||
|
#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
|
||||||
|
|
||||||
|
#define NO_THREAD_SAFETY_ANALYSIS THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
|
||||||
|
|
||||||
|
class Condition;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: This class is for code that builds on Win32. Its usage is
|
||||||
|
* deprecated for code which doesn't build for Win32. New code which
|
||||||
|
* doesn't build for Win32 should use std::mutex and std::lock_guard instead.
|
||||||
|
*
|
||||||
|
* Simple mutex class. The implementation is system-dependent.
|
||||||
|
*
|
||||||
|
* The mutex must be unlocked by the thread that locked it. They are not
|
||||||
|
* recursive, i.e. the same thread can't lock it multiple times.
|
||||||
|
*/
|
||||||
|
class CAPABILITY("mutex") Mutex {
|
||||||
|
public:
|
||||||
|
enum {
|
||||||
|
PRIVATE = 0,
|
||||||
|
SHARED = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
Mutex();
|
||||||
|
explicit Mutex(const char* name);
|
||||||
|
explicit Mutex(int type, const char* name = nullptr);
|
||||||
|
~Mutex();
|
||||||
|
|
||||||
|
// lock or unlock the mutex
|
||||||
|
int32_t lock() ACQUIRE();
|
||||||
|
void unlock() RELEASE();
|
||||||
|
|
||||||
|
// lock if possible; returns 0 on success, error otherwise
|
||||||
|
int32_t tryLock() TRY_ACQUIRE(0);
|
||||||
|
|
||||||
|
int32_t timedLock(int64_t timeoutNs) TRY_ACQUIRE(0);
|
||||||
|
|
||||||
|
// Manages the mutex automatically. It'll be locked when Autolock is
|
||||||
|
// constructed and released when Autolock goes out of scope.
|
||||||
|
class SCOPED_CAPABILITY Autolock {
|
||||||
|
public:
|
||||||
|
inline explicit Autolock(Mutex& mutex) ACQUIRE(mutex) : mLock(mutex) {
|
||||||
|
mLock.lock();
|
||||||
|
}
|
||||||
|
inline explicit Autolock(Mutex* mutex) ACQUIRE(mutex) : mLock(*mutex) {
|
||||||
|
mLock.lock();
|
||||||
|
}
|
||||||
|
inline ~Autolock() RELEASE() {
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Mutex& mLock;
|
||||||
|
// Cannot be copied or moved - declarations only
|
||||||
|
Autolock(const Autolock&);
|
||||||
|
Autolock& operator=(const Autolock&);
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class Condition;
|
||||||
|
|
||||||
|
// A mutex cannot be copied
|
||||||
|
Mutex(const Mutex&);
|
||||||
|
Mutex& operator=(const Mutex&);
|
||||||
|
|
||||||
|
pthread_mutex_t mMutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
inline Mutex::Mutex() {
|
||||||
|
pthread_mutex_init(&mMutex, nullptr);
|
||||||
|
}
|
||||||
|
inline Mutex::Mutex(__attribute__((unused)) const char* name) {
|
||||||
|
pthread_mutex_init(&mMutex, nullptr);
|
||||||
|
}
|
||||||
|
inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) {
|
||||||
|
if (type == SHARED) {
|
||||||
|
pthread_mutexattr_t attr;
|
||||||
|
pthread_mutexattr_init(&attr);
|
||||||
|
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||||
|
pthread_mutex_init(&mMutex, &attr);
|
||||||
|
pthread_mutexattr_destroy(&attr);
|
||||||
|
} else {
|
||||||
|
pthread_mutex_init(&mMutex, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inline Mutex::~Mutex() {
|
||||||
|
pthread_mutex_destroy(&mMutex);
|
||||||
|
}
|
||||||
|
inline int32_t Mutex::lock() {
|
||||||
|
return -pthread_mutex_lock(&mMutex);
|
||||||
|
}
|
||||||
|
inline void Mutex::unlock() {
|
||||||
|
pthread_mutex_unlock(&mMutex);
|
||||||
|
}
|
||||||
|
inline int32_t Mutex::tryLock() {
|
||||||
|
return -pthread_mutex_trylock(&mMutex);
|
||||||
|
}
|
||||||
|
inline int32_t Mutex::timedLock(int64_t timeoutNs) {
|
||||||
|
timespec now;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
|
timeoutNs += now.tv_sec*1000000000 + now.tv_nsec;
|
||||||
|
const struct timespec ts = {
|
||||||
|
/* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),
|
||||||
|
/* .tv_nsec = */ static_cast<long>(timeoutNs % 1000000000),
|
||||||
|
};
|
||||||
|
return -pthread_mutex_timedlock(&mMutex, &ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Automatic mutex. Declare one of these at the top of a function.
|
||||||
|
* When the function returns, it will go out of scope, and release the
|
||||||
|
* mutex.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef Mutex::Autolock AutoMutex;
|
||||||
|
#endif // __ANDROID_VNDK__
|
||||||
|
#endif // _LIBS_RGA_MUTEX_H
|
70
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RgaSingleton.h
vendored
Normal file
70
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RgaSingleton.h
vendored
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Zhiqin Wei <wzq@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBS_RGA_SINGLETON_H
|
||||||
|
#define _LIBS_RGA_SINGLETON_H
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
|
#include "RgaMutex.h"
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wundefined-var-template"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename TYPE>
|
||||||
|
class Singleton {
|
||||||
|
public:
|
||||||
|
static TYPE& getInstance() {
|
||||||
|
Mutex::Autolock _l(sLock);
|
||||||
|
TYPE* instance = sInstance;
|
||||||
|
if (instance == nullptr) {
|
||||||
|
instance = new TYPE();
|
||||||
|
sInstance = instance;
|
||||||
|
}
|
||||||
|
return *instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool hasInstance() {
|
||||||
|
Mutex::Autolock _l(sLock);
|
||||||
|
return sInstance != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~Singleton() { }
|
||||||
|
Singleton() { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Singleton(const Singleton&);
|
||||||
|
Singleton& operator = (const Singleton&);
|
||||||
|
static Mutex sLock;
|
||||||
|
static TYPE* sInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RGA_SINGLETON_STATIC_INSTANCE(TYPE) \
|
||||||
|
template<> ::Mutex \
|
||||||
|
(::Singleton< TYPE >::sLock)(::Mutex::PRIVATE); \
|
||||||
|
template<> TYPE* ::Singleton< TYPE >::sInstance(nullptr); /* NOLINT */ \
|
||||||
|
template class ::Singleton< TYPE >;
|
||||||
|
|
||||||
|
#endif //ANDROID
|
||||||
|
#endif //_LIBS_RGA_SINGLETON_H
|
31
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RgaUtils.h
vendored
Normal file
31
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RgaUtils.h
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Zhiqin Wei <wzq@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _rga_utils_h_
|
||||||
|
#define _rga_utils_h_
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------
|
||||||
|
float get_bpp_from_format(int format);
|
||||||
|
int get_perPixel_stride_from_format(int format);
|
||||||
|
int get_buf_from_file(void *buf, int f, int sw, int sh, int index);
|
||||||
|
int output_buf_data_to_file(void *buf, int f, int sw, int sh, int index);
|
||||||
|
const char *translate_format_str(int format);
|
||||||
|
int get_buf_from_file_FBC(void *buf, int f, int sw, int sh, int index);
|
||||||
|
int output_buf_data_to_file_FBC(void *buf, int f, int sw, int sh, int index);
|
||||||
|
#endif
|
||||||
|
|
110
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RockchipRga.h
vendored
Normal file
110
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/RockchipRga.h
vendored
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Zhiqin Wei <wzq@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _rockchip_rga_h_
|
||||||
|
#define _rockchip_rga_h_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <linux/stddef.h>
|
||||||
|
|
||||||
|
#include "drmrga.h"
|
||||||
|
#include "GrallocOps.h"
|
||||||
|
#include "RgaUtils.h"
|
||||||
|
#include "rga.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef ANDROID
|
||||||
|
#include "RgaSingleton.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
#include <utils/Singleton.h>
|
||||||
|
#include <utils/Thread.h>
|
||||||
|
#include <hardware/hardware.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class RockchipRga :public Singleton<RockchipRga> {
|
||||||
|
public:
|
||||||
|
|
||||||
|
static inline RockchipRga& get() {
|
||||||
|
return getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
int RkRgaInit();
|
||||||
|
void RkRgaDeInit();
|
||||||
|
void RkRgaGetContext(void **ctx);
|
||||||
|
#ifndef ANDROID /* LINUX */
|
||||||
|
int RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
|
||||||
|
int width, int height, int bpp, int flags);
|
||||||
|
int RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
|
||||||
|
int RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||||
|
int RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
|
||||||
|
int RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
|
||||||
|
int RkRgaGetMmap(bo_t *bo_info);
|
||||||
|
int RkRgaUnmap(bo_t *bo_info);
|
||||||
|
int RkRgaFree(bo_t *bo_info);
|
||||||
|
int RkRgaGetBufferFd(bo_t *bo_info, int *fd);
|
||||||
|
#else
|
||||||
|
int RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
|
||||||
|
int RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
|
||||||
|
#endif
|
||||||
|
int RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
|
||||||
|
int RkRgaCollorFill(rga_info *dst);
|
||||||
|
int RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
|
||||||
|
int RkRgaFlush();
|
||||||
|
|
||||||
|
|
||||||
|
void RkRgaSetLogOnceFlag(int log) {
|
||||||
|
mLogOnce = log;
|
||||||
|
}
|
||||||
|
void RkRgaSetAlwaysLogFlag(bool log) {
|
||||||
|
mLogAlways = log;
|
||||||
|
}
|
||||||
|
void RkRgaLogOutRgaReq(struct rga_req rgaReg);
|
||||||
|
int RkRgaLogOutUserPara(rga_info *rgaInfo);
|
||||||
|
inline bool RkRgaIsReady() {
|
||||||
|
return mSupportRga;
|
||||||
|
}
|
||||||
|
|
||||||
|
RockchipRga();
|
||||||
|
~RockchipRga();
|
||||||
|
private:
|
||||||
|
bool mSupportRga;
|
||||||
|
int mLogOnce;
|
||||||
|
int mLogAlways;
|
||||||
|
void * mContext;
|
||||||
|
|
||||||
|
friend class Singleton<RockchipRga>;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
}; // namespace android
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
358
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/drmrga.h
vendored
Normal file
358
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/drmrga.h
vendored
Normal file
|
@ -0,0 +1,358 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Zhiqin Wei <wzq@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _rk_drm_rga_
|
||||||
|
#define _rk_drm_rga_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#include "rga.h"
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
#define DRMRGA_HARDWARE_MODULE_ID "librga"
|
||||||
|
|
||||||
|
#include <hardware/gralloc.h>
|
||||||
|
#include <hardware/hardware.h>
|
||||||
|
#include <system/graphics.h>
|
||||||
|
#include <cutils/native_handle.h>
|
||||||
|
|
||||||
|
#ifdef ANDROID_12
|
||||||
|
#include <hardware/hardware_rockchip.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RGA_BLIT_SYNC 0x5017
|
||||||
|
#define RGA_BLIT_ASYNC 0x5018
|
||||||
|
|
||||||
|
#ifndef ANDROID /* LINUX */
|
||||||
|
/* flip source image horizontally (around the vertical axis) */
|
||||||
|
#define HAL_TRANSFORM_FLIP_H 0x01
|
||||||
|
/* flip source image vertically (around the horizontal axis)*/
|
||||||
|
#define HAL_TRANSFORM_FLIP_V 0x02
|
||||||
|
/* rotate source image 90 degrees clockwise */
|
||||||
|
#define HAL_TRANSFORM_ROT_90 0x04
|
||||||
|
/* rotate source image 180 degrees */
|
||||||
|
#define HAL_TRANSFORM_ROT_180 0x03
|
||||||
|
/* rotate source image 270 degrees clockwise */
|
||||||
|
#define HAL_TRANSFORM_ROT_270 0x07
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HAL_TRANSFORM_FLIP_H_V 0x08
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/* for compatibility */
|
||||||
|
#define DRM_RGA_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1
|
||||||
|
#define DRM_RGA_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1
|
||||||
|
#define DRM_RGA_API_VERSION HWC_DEVICE_API_VERSION
|
||||||
|
|
||||||
|
#define DRM_RGA_TRANSFORM_ROT_MASK 0x0000000F
|
||||||
|
#define DRM_RGA_TRANSFORM_ROT_0 0x00000000
|
||||||
|
#define DRM_RGA_TRANSFORM_ROT_90 HAL_TRANSFORM_ROT_90
|
||||||
|
#define DRM_RGA_TRANSFORM_ROT_180 HAL_TRANSFORM_ROT_180
|
||||||
|
#define DRM_RGA_TRANSFORM_ROT_270 HAL_TRANSFORM_ROT_270
|
||||||
|
|
||||||
|
#define DRM_RGA_TRANSFORM_FLIP_MASK 0x00000003
|
||||||
|
#define DRM_RGA_TRANSFORM_FLIP_H HAL_TRANSFORM_FLIP_H
|
||||||
|
#define DRM_RGA_TRANSFORM_FLIP_V HAL_TRANSFORM_FLIP_V
|
||||||
|
|
||||||
|
enum {
|
||||||
|
AWIDTH = 0,
|
||||||
|
AHEIGHT,
|
||||||
|
ASTRIDE,
|
||||||
|
AFORMAT,
|
||||||
|
ASIZE,
|
||||||
|
ATYPE,
|
||||||
|
};
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ANDROID /* LINUX */
|
||||||
|
/* memory type definitions. */
|
||||||
|
enum drm_rockchip_gem_mem_type {
|
||||||
|
/* Physically Continuous memory and used as default. */
|
||||||
|
ROCKCHIP_BO_CONTIG = 1 << 0,
|
||||||
|
/* cachable mapping. */
|
||||||
|
ROCKCHIP_BO_CACHABLE = 1 << 1,
|
||||||
|
/* write-combine mapping. */
|
||||||
|
ROCKCHIP_BO_WC = 1 << 2,
|
||||||
|
ROCKCHIP_BO_SECURE = 1 << 3,
|
||||||
|
ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE |
|
||||||
|
ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct bo {
|
||||||
|
int fd;
|
||||||
|
void *ptr;
|
||||||
|
size_t size;
|
||||||
|
size_t offset;
|
||||||
|
size_t pitch;
|
||||||
|
unsigned handle;
|
||||||
|
} bo_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
@value size: user not need care about.For avoid read/write out of memory
|
||||||
|
*/
|
||||||
|
typedef struct rga_rect {
|
||||||
|
int xoffset;
|
||||||
|
int yoffset;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int wstride;
|
||||||
|
int hstride;
|
||||||
|
int format;
|
||||||
|
int size;
|
||||||
|
} rga_rect_t;
|
||||||
|
|
||||||
|
typedef struct rga_nn {
|
||||||
|
int nn_flag;
|
||||||
|
int scale_r;
|
||||||
|
int scale_g;
|
||||||
|
int scale_b;
|
||||||
|
int offset_r;
|
||||||
|
int offset_g;
|
||||||
|
int offset_b;
|
||||||
|
} rga_nn_t;
|
||||||
|
|
||||||
|
typedef struct rga_dither {
|
||||||
|
int enable;
|
||||||
|
int mode;
|
||||||
|
int lut0_l;
|
||||||
|
int lut0_h;
|
||||||
|
int lut1_l;
|
||||||
|
int lut1_h;
|
||||||
|
} rga_dither_t;
|
||||||
|
|
||||||
|
struct rga_mosaic_info {
|
||||||
|
uint8_t enable;
|
||||||
|
uint8_t mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rga_pre_intr_info {
|
||||||
|
uint8_t enable;
|
||||||
|
|
||||||
|
uint8_t read_intr_en;
|
||||||
|
uint8_t write_intr_en;
|
||||||
|
uint8_t read_hold_en;
|
||||||
|
uint32_t read_threshold;
|
||||||
|
uint32_t write_start;
|
||||||
|
uint32_t write_step;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* MAX(min, (max - channel_value)) */
|
||||||
|
struct rga_osd_invert_factor {
|
||||||
|
uint8_t alpha_max;
|
||||||
|
uint8_t alpha_min;
|
||||||
|
uint8_t yg_max;
|
||||||
|
uint8_t yg_min;
|
||||||
|
uint8_t crb_max;
|
||||||
|
uint8_t crb_min;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rga_color {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint8_t red;
|
||||||
|
uint8_t green;
|
||||||
|
uint8_t blue;
|
||||||
|
uint8_t alpha;
|
||||||
|
};
|
||||||
|
uint32_t value;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rga_osd_bpp2 {
|
||||||
|
uint8_t ac_swap; // ac swap flag
|
||||||
|
// 0: CA
|
||||||
|
// 1: AC
|
||||||
|
uint8_t endian_swap; // rgba2bpp endian swap
|
||||||
|
// 0: Big endian
|
||||||
|
// 1: Little endian
|
||||||
|
struct rga_color color0;
|
||||||
|
struct rga_color color1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rga_osd_mode_ctrl {
|
||||||
|
uint8_t mode; // OSD cal mode:
|
||||||
|
// 0b'1: statistics mode
|
||||||
|
// 1b'1: auto inversion overlap mode
|
||||||
|
uint8_t direction_mode; // horizontal or vertical
|
||||||
|
// 0: horizontal
|
||||||
|
// 1: vertical
|
||||||
|
uint8_t width_mode; // using @fix_width or LUT width
|
||||||
|
// 0: fix width
|
||||||
|
// 1: LUT width
|
||||||
|
uint16_t block_fix_width; // OSD block fixed width
|
||||||
|
// real width = (fix_width + 1) * 2
|
||||||
|
uint8_t block_num; // OSD block num
|
||||||
|
uint16_t flags_index; // auto invert flags index
|
||||||
|
|
||||||
|
/* invertion config */
|
||||||
|
uint8_t color_mode; // selete color
|
||||||
|
// 0: src1 color
|
||||||
|
// 1: config data color
|
||||||
|
uint8_t invert_flags_mode; // invert flag selete
|
||||||
|
// 0: use RAM flag
|
||||||
|
// 1: usr last result
|
||||||
|
uint8_t default_color_sel; // default color mode
|
||||||
|
// 0: default is bright
|
||||||
|
// 1: default is dark
|
||||||
|
uint8_t invert_enable; // invert channel enable
|
||||||
|
// 1 << 0: aplha enable
|
||||||
|
// 1 << 1: Y/G disable
|
||||||
|
// 1 << 2: C/RB disable
|
||||||
|
uint8_t invert_mode; // invert cal mode
|
||||||
|
// 0: normal(max-data)
|
||||||
|
// 1: swap
|
||||||
|
uint8_t invert_thresh; // if luma > thresh, osd_flag to be 1
|
||||||
|
uint8_t unfix_index; // OSD width config index
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rga_osd_info {
|
||||||
|
uint8_t enable;
|
||||||
|
|
||||||
|
struct rga_osd_mode_ctrl mode_ctrl;
|
||||||
|
struct rga_osd_invert_factor cal_factor;
|
||||||
|
struct rga_osd_bpp2 bpp2_info;
|
||||||
|
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint32_t last_flags1;
|
||||||
|
uint32_t last_flags0;
|
||||||
|
};
|
||||||
|
uint64_t last_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint32_t cur_flags1;
|
||||||
|
uint32_t cur_flags0;
|
||||||
|
};
|
||||||
|
uint64_t cur_flags;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
@value fd: use fd to share memory, it can be ion shard fd,and dma fd.
|
||||||
|
@value virAddr:userspace address
|
||||||
|
@value phyAddr:use phy address
|
||||||
|
@value hnd: use buffer_handle_t
|
||||||
|
*/
|
||||||
|
typedef struct rga_info {
|
||||||
|
int fd;
|
||||||
|
void *virAddr;
|
||||||
|
void *phyAddr;
|
||||||
|
#ifndef ANDROID /* LINUX */
|
||||||
|
unsigned hnd;
|
||||||
|
#else /* Android */
|
||||||
|
buffer_handle_t hnd;
|
||||||
|
#endif
|
||||||
|
int format;
|
||||||
|
rga_rect_t rect;
|
||||||
|
unsigned int blend;
|
||||||
|
int bufferSize;
|
||||||
|
int rotation;
|
||||||
|
int color;
|
||||||
|
int testLog;
|
||||||
|
int mmuFlag;
|
||||||
|
int colorkey_en;
|
||||||
|
int colorkey_mode;
|
||||||
|
int colorkey_max;
|
||||||
|
int colorkey_min;
|
||||||
|
int scale_mode;
|
||||||
|
int color_space_mode;
|
||||||
|
int sync_mode;
|
||||||
|
rga_nn_t nn;
|
||||||
|
rga_dither_t dither;
|
||||||
|
int rop_code;
|
||||||
|
int rd_mode;
|
||||||
|
unsigned short is_10b_compact;
|
||||||
|
unsigned short is_10b_endian;
|
||||||
|
|
||||||
|
int in_fence_fd;
|
||||||
|
int out_fence_fd;
|
||||||
|
|
||||||
|
int core;
|
||||||
|
int priority;
|
||||||
|
|
||||||
|
unsigned short enable;
|
||||||
|
|
||||||
|
int handle;
|
||||||
|
|
||||||
|
struct rga_mosaic_info mosaic_info;
|
||||||
|
|
||||||
|
struct rga_osd_info osd_info;
|
||||||
|
|
||||||
|
struct rga_pre_intr_info pre_intr;
|
||||||
|
|
||||||
|
int mpi_mode;
|
||||||
|
|
||||||
|
union {
|
||||||
|
int ctx_id;
|
||||||
|
int job_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
char reserve[402];
|
||||||
|
} rga_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct drm_rga {
|
||||||
|
rga_rect_t src;
|
||||||
|
rga_rect_t dst;
|
||||||
|
} drm_rga_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
@fun rga_set_rect:For use to set the rects esayly
|
||||||
|
|
||||||
|
@param rect:The rect user want to set,like setting the src rect:
|
||||||
|
drm_rga_t rects;
|
||||||
|
rga_set_rect(rects.src,0,0,1920,1080,1920,NV12);
|
||||||
|
mean to set the src rect to the value.
|
||||||
|
*/
|
||||||
|
static inline int rga_set_rect(rga_rect_t *rect,
|
||||||
|
int x, int y, int w, int h, int sw, int sh, int f) {
|
||||||
|
if (!rect)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
rect->xoffset = x;
|
||||||
|
rect->yoffset = y;
|
||||||
|
rect->width = w;
|
||||||
|
rect->height = h;
|
||||||
|
rect->wstride = sw;
|
||||||
|
rect->hstride = sh;
|
||||||
|
rect->format = f;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef ANDROID /* LINUX */
|
||||||
|
static inline void rga_set_rotation(rga_info_t *info, int angle) {
|
||||||
|
if (angle == 90)
|
||||||
|
info->rotation = HAL_TRANSFORM_ROT_90;
|
||||||
|
else if (angle == 180)
|
||||||
|
info->rotation = HAL_TRANSFORM_ROT_180;
|
||||||
|
else if (angle == 270)
|
||||||
|
info->rotation = HAL_TRANSFORM_ROT_270;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#endif
|
32
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d.h
vendored
Normal file
32
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d.h
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* PutinLee <putin.lee@rock-chips.com>
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _im2d_h_
|
||||||
|
#define _im2d_h_
|
||||||
|
|
||||||
|
#include "im2d_version.h"
|
||||||
|
#include "im2d_type.h"
|
||||||
|
|
||||||
|
#include "im2d_common.h"
|
||||||
|
#include "im2d_buffer.h"
|
||||||
|
#include "im2d_single.h"
|
||||||
|
#include "im2d_task.h"
|
||||||
|
#include "im2d_mpi.h"
|
||||||
|
|
||||||
|
#endif /* #ifndef _im2d_h_ */
|
27
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d.hpp
vendored
Normal file
27
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d.hpp
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* PutinLee <putin.lee@rock-chips.com>
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _im2d_hpp_
|
||||||
|
#define _im2d_hpp_
|
||||||
|
|
||||||
|
#include "im2d.h"
|
||||||
|
#include "im2d_expand.h"
|
||||||
|
|
||||||
|
#endif /* #ifndef _im2d_hpp_ */
|
||||||
|
|
||||||
|
|
179
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_buffer.h
vendored
Normal file
179
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_buffer.h
vendored
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _im2d_buffer_h_
|
||||||
|
#define _im2d_buffer_h_
|
||||||
|
|
||||||
|
#include "im2d_type.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import external buffers into RGA driver.
|
||||||
|
*
|
||||||
|
* @param fd/va/pa
|
||||||
|
* Select dma_fd/virtual_address/physical_address by buffer type
|
||||||
|
* @param size
|
||||||
|
* Describes the size of the image buffer
|
||||||
|
*
|
||||||
|
* @return rga_buffer_handle_t
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
IM_API rga_buffer_handle_t importbuffer_fd(int fd, int size);
|
||||||
|
IM_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, int size);
|
||||||
|
IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, int size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import external buffers into RGA driver.
|
||||||
|
*
|
||||||
|
* @param fd/va/pa
|
||||||
|
* Select dma_fd/virtual_address/physical_address by buffer type
|
||||||
|
* @param width
|
||||||
|
* Describes the pixel width stride of the image buffer
|
||||||
|
* @param height
|
||||||
|
* Describes the pixel height stride of the image buffer
|
||||||
|
* @param format
|
||||||
|
* Describes the pixel format of the image buffer
|
||||||
|
*
|
||||||
|
* @return rga_buffer_handle_t
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
IM_API rga_buffer_handle_t importbuffer_fd(int fd, int width, int height, int format);
|
||||||
|
IM_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, int width, int height, int format);
|
||||||
|
IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, int width, int height, int format);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import external buffers into RGA driver.
|
||||||
|
*
|
||||||
|
* @param fd/va/pa
|
||||||
|
* Select dma_fd/virtual_address/physical_address by buffer type
|
||||||
|
* @param param
|
||||||
|
* Configure buffer parameters
|
||||||
|
*
|
||||||
|
* @return rga_buffer_handle_t
|
||||||
|
*/
|
||||||
|
IM_EXPORT_API rga_buffer_handle_t importbuffer_fd(int fd, im_handle_param_t *param);
|
||||||
|
IM_EXPORT_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, im_handle_param_t *param);
|
||||||
|
IM_EXPORT_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, im_handle_param_t *param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import external buffers into RGA driver.
|
||||||
|
*
|
||||||
|
* @param handle
|
||||||
|
* rga buffer handle
|
||||||
|
*
|
||||||
|
* @return success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_EXPORT_API IM_STATUS releasebuffer_handle(rga_buffer_handle_t handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap image Parameters.
|
||||||
|
*
|
||||||
|
* @param handle/virtualaddr/physicaladdr/fd
|
||||||
|
* RGA buffer handle/virtualaddr/physicaladdr/fd.
|
||||||
|
* @param width
|
||||||
|
* Width of image manipulation area.
|
||||||
|
* @param height
|
||||||
|
* Height of image manipulation area.
|
||||||
|
* @param wstride
|
||||||
|
* Width pixel stride, default (width = wstride).
|
||||||
|
* @param hstride
|
||||||
|
* Height pixel stride, default (height = hstride).
|
||||||
|
* @param format
|
||||||
|
* Image format.
|
||||||
|
*
|
||||||
|
* @return rga_buffer_t
|
||||||
|
*/
|
||||||
|
#define wrapbuffer_handle(handle, width, height, format, ...) \
|
||||||
|
({ \
|
||||||
|
rga_buffer_t im2d_api_buffer; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
im2d_api_buffer = wrapbuffer_handle_t(handle, width, height, width, height, format); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
im2d_api_buffer = wrapbuffer_handle_t(handle, width, height, __args[0], __args[1], format); \
|
||||||
|
} else { \
|
||||||
|
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
im2d_api_buffer; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define wrapbuffer_virtualaddr(vir_addr, width, height, format, ...) \
|
||||||
|
({ \
|
||||||
|
rga_buffer_t im2d_api_buffer; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
im2d_api_buffer = wrapbuffer_virtualaddr_t(vir_addr, width, height, width, height, format); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
im2d_api_buffer = wrapbuffer_virtualaddr_t(vir_addr, width, height, __args[0], __args[1], format); \
|
||||||
|
} else { \
|
||||||
|
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
im2d_api_buffer; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define wrapbuffer_physicaladdr(phy_addr, width, height, format, ...) \
|
||||||
|
({ \
|
||||||
|
rga_buffer_t im2d_api_buffer; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
im2d_api_buffer = wrapbuffer_physicaladdr_t(phy_addr, width, height, width, height, format); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
im2d_api_buffer = wrapbuffer_physicaladdr_t(phy_addr, width, height, __args[0], __args[1], format); \
|
||||||
|
} else { \
|
||||||
|
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
im2d_api_buffer; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define wrapbuffer_fd(fd, width, height, format, ...) \
|
||||||
|
({ \
|
||||||
|
rga_buffer_t im2d_api_buffer; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
im2d_api_buffer = wrapbuffer_fd_t(fd, width, height, width, height, format); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
im2d_api_buffer = wrapbuffer_fd_t(fd, width, height, __args[0], __args[1], format); \
|
||||||
|
} else { \
|
||||||
|
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
im2d_api_buffer; \
|
||||||
|
})
|
||||||
|
/* Symbols for define *_t functions */
|
||||||
|
IM_C_API rga_buffer_t wrapbuffer_handle_t(rga_buffer_handle_t handle, int width, int height, int wstride, int hstride, int format);
|
||||||
|
IM_C_API rga_buffer_t wrapbuffer_virtualaddr_t(void* vir_addr, int width, int height, int wstride, int hstride, int format);
|
||||||
|
IM_C_API rga_buffer_t wrapbuffer_physicaladdr_t(void* phy_addr, int width, int height, int wstride, int hstride, int format);
|
||||||
|
IM_C_API rga_buffer_t wrapbuffer_fd_t(int fd, int width, int height, int wstride, int hstride, int format);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#undef wrapbuffer_handle
|
||||||
|
IM_API rga_buffer_t wrapbuffer_handle(rga_buffer_handle_t handle,
|
||||||
|
int width, int height, int format);
|
||||||
|
IM_API rga_buffer_t wrapbuffer_handle(rga_buffer_handle_t handle,
|
||||||
|
int width, int height, int format,
|
||||||
|
int wstride, int hstride);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* #ifndef _im2d_buffer_h_ */
|
151
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_common.h
vendored
Normal file
151
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_common.h
vendored
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _im2d_common_h_
|
||||||
|
#define _im2d_common_h_
|
||||||
|
|
||||||
|
#include "im2d_type.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query RGA basic information, supported resolution, supported format, etc.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* RGA_VENDOR
|
||||||
|
* RGA_VERSION
|
||||||
|
* RGA_MAX_INPUT
|
||||||
|
* RGA_MAX_OUTPUT
|
||||||
|
* RGA_INPUT_FORMAT
|
||||||
|
* RGA_OUTPUT_FORMAT
|
||||||
|
* RGA_EXPECTED
|
||||||
|
* RGA_ALL
|
||||||
|
*
|
||||||
|
* @returns a string describing properties of RGA.
|
||||||
|
*/
|
||||||
|
IM_EXPORT_API const char* querystring(int name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String to output the error message
|
||||||
|
*
|
||||||
|
* @param status
|
||||||
|
* process result value.
|
||||||
|
*
|
||||||
|
* @returns error message.
|
||||||
|
*/
|
||||||
|
#define imStrError(...) \
|
||||||
|
({ \
|
||||||
|
const char* im2d_api_err; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
im2d_api_err = imStrError_t(IM_STATUS_INVALID_PARAM); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
im2d_api_err = imStrError_t((IM_STATUS)__args[0]); \
|
||||||
|
} else { \
|
||||||
|
im2d_api_err = ("Fatal error, imStrError() too many parameters\n"); \
|
||||||
|
printf("Fatal error, imStrError() too many parameters\n"); \
|
||||||
|
} \
|
||||||
|
im2d_api_err; \
|
||||||
|
})
|
||||||
|
IM_C_API const char* imStrError_t(IM_STATUS status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check im2d api header file
|
||||||
|
*
|
||||||
|
* @param header_version
|
||||||
|
* Default is RGA_CURRENT_API_HEADER_VERSION, no need to change if there are no special cases.
|
||||||
|
*
|
||||||
|
* @returns no error or else negative error code.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
IM_API IM_STATUS imcheckHeader(im_api_version_t header_version = RGA_CURRENT_API_HEADER_VERSION);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check RGA basic information, supported resolution, supported format, etc.
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param pat
|
||||||
|
* @param src_rect
|
||||||
|
* @param dst_rect
|
||||||
|
* @param pat_rect
|
||||||
|
* @param mode_usage
|
||||||
|
*
|
||||||
|
* @returns no error or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imcheck(src, dst, src_rect, dst_rect, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_NOERROR; \
|
||||||
|
rga_buffer_t __pat; \
|
||||||
|
im_rect __pat_rect; \
|
||||||
|
memset(&__pat, 0, sizeof(rga_buffer_t)); \
|
||||||
|
memset(&__pat_rect, 0, sizeof(im_rect)); \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imcheck_t(src, dst, __pat, src_rect, dst_rect, __pat_rect, 0); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imcheck_t(src, dst, __pat, src_rect, dst_rect, __pat_rect, __args[0]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_FAILED; \
|
||||||
|
printf("check failed\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
#define imcheck_composite(src, dst, pat, src_rect, dst_rect, pat_rect, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_NOERROR; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, 0); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, __args[0]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_FAILED; \
|
||||||
|
printf("check failed\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
IM_C_API IM_STATUS imcheck_t(const rga_buffer_t src, const rga_buffer_t dst, const rga_buffer_t pat,
|
||||||
|
const im_rect src_rect, const im_rect dst_rect, const im_rect pat_rect, const int mode_usage);
|
||||||
|
/* Compatible with the legacy symbol */
|
||||||
|
IM_C_API void rga_check_perpare(rga_buffer_t *src, rga_buffer_t *dst, rga_buffer_t *pat,
|
||||||
|
im_rect *src_rect, im_rect *dst_rect, im_rect *pat_rect, int mode_usage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* block until all execution is complete
|
||||||
|
*
|
||||||
|
* @param release_fence_fd
|
||||||
|
* RGA job release fence fd
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_EXPORT_API IM_STATUS imsync(int release_fence_fd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* config
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* enum IM_CONFIG_NAME
|
||||||
|
* @param value
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_EXPORT_API IM_STATUS imconfig(IM_CONFIG_NAME name, uint64_t value);
|
||||||
|
|
||||||
|
#endif /* #ifndef _im2d_common_h_ */
|
47
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_expand.h
vendored
Normal file
47
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_expand.h
vendored
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _im2d_expand_h_
|
||||||
|
#define _im2d_expand_h_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include "im2d_type.h"
|
||||||
|
|
||||||
|
// #if ANDROID
|
||||||
|
|
||||||
|
// #include <ui/GraphicBuffer.h>
|
||||||
|
|
||||||
|
// using namespace android;
|
||||||
|
|
||||||
|
// IM_API rga_buffer_handle_t importbuffer_GraphicBuffer_handle(buffer_handle_t hnd);
|
||||||
|
// IM_API rga_buffer_handle_t importbuffer_GraphicBuffer(sp<GraphicBuffer> buf);
|
||||||
|
|
||||||
|
// IM_API rga_buffer_t wrapbuffer_handle(buffer_handle_t hnd);
|
||||||
|
// IM_API rga_buffer_t wrapbuffer_GraphicBuffer(sp<GraphicBuffer> buf);
|
||||||
|
|
||||||
|
// #if USE_AHARDWAREBUFFER
|
||||||
|
// #include <android/hardware_buffer.h>
|
||||||
|
// IM_API rga_buffer_handle_t importbuffer_AHardwareBuffer(AHardwareBuffer *buf);
|
||||||
|
// IM_API rga_buffer_t wrapbuffer_AHardwareBuffer(AHardwareBuffer *buf);
|
||||||
|
|
||||||
|
// #endif /* #if USE_AHARDWAREBUFFER */
|
||||||
|
// #endif /* #if ANDROID */
|
||||||
|
|
||||||
|
#endif /* #ifdef __cplusplus */
|
||||||
|
|
||||||
|
#endif
|
80
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_mpi.h
vendored
Normal file
80
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_mpi.h
vendored
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _im2d_mpi_hpp_
|
||||||
|
#define _im2d_mpi_hpp_
|
||||||
|
|
||||||
|
#include "im2d_type.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and config an rga ctx for rockit-ko
|
||||||
|
*
|
||||||
|
* @param flags
|
||||||
|
* Some configuration flags for this job
|
||||||
|
*
|
||||||
|
* @returns job id.
|
||||||
|
*/
|
||||||
|
IM_EXPORT_API im_ctx_id_t imbegin(uint32_t flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel and delete an rga ctx for rockit-ko
|
||||||
|
*
|
||||||
|
* @param flags
|
||||||
|
* Some configuration flags for this job
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_EXPORT_API IM_STATUS imcancel(im_ctx_id_t id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* process for rockit-ko
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image and is also the foreground image in blend.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image and is also the foreground image in blend.
|
||||||
|
* @param pat
|
||||||
|
* The foreground image, or a LUT table.
|
||||||
|
* @param srect
|
||||||
|
* The rectangle on the src channel image that needs to be processed.
|
||||||
|
* @param drect
|
||||||
|
* The rectangle on the dst channel image that needs to be processed.
|
||||||
|
* @param prect
|
||||||
|
* The rectangle on the pat channel image that needs to be processed.
|
||||||
|
* @param acquire_fence_fd
|
||||||
|
* @param release_fence_fd
|
||||||
|
* @param opt
|
||||||
|
* The image processing options configuration.
|
||||||
|
* @param usage
|
||||||
|
* The image processing usage.
|
||||||
|
* @param ctx_id
|
||||||
|
* ctx id
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
IM_API IM_STATUS improcess(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
|
||||||
|
im_rect srect, im_rect drect, im_rect prect,
|
||||||
|
int acquire_fence_fd, int *release_fence_fd,
|
||||||
|
im_opt_t *opt, int usage, im_ctx_id_t ctx_id);
|
||||||
|
#endif
|
||||||
|
IM_EXPORT_API IM_STATUS improcess_ctx(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
|
||||||
|
im_rect srect, im_rect drect, im_rect prect,
|
||||||
|
int acquire_fence_fd, int *release_fence_fd,
|
||||||
|
im_opt_t *opt, int usage, im_ctx_id_t ctx_id);
|
||||||
|
|
||||||
|
#endif /* #ifndef _im2d_mpi_hpp_ */
|
940
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_single.h
vendored
Normal file
940
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_single.h
vendored
Normal file
|
@ -0,0 +1,940 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _im2d_single_h_
|
||||||
|
#define _im2d_single_h_
|
||||||
|
|
||||||
|
#include "im2d_type.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copy
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcopy(const rga_buffer_t src, rga_buffer_t dst, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resize
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param fx
|
||||||
|
* X-direction resize factor.
|
||||||
|
* @param fy
|
||||||
|
* X-direction resize factor.
|
||||||
|
* @param interpolation
|
||||||
|
* Interpolation formula(Only RGA1 support).
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imresize(const rga_buffer_t src, rga_buffer_t dst, double fx = 0, double fy = 0, int interpolation = 0, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crop
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect
|
||||||
|
* The rectangle on the source image that needs to be cropped.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcrop(const rga_buffer_t src, rga_buffer_t dst, im_rect rect, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* translate
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param x
|
||||||
|
* Output the coordinates of the starting point in the X-direction of the destination image.
|
||||||
|
* @param y
|
||||||
|
* Output the coordinates of the starting point in the Y-direction of the destination image.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imtranslate(const rga_buffer_t src, rga_buffer_t dst, int x, int y, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* format convert
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param sfmt
|
||||||
|
* The source image format.
|
||||||
|
* @param dfmt
|
||||||
|
* The destination image format.
|
||||||
|
* @param mode
|
||||||
|
* color space mode:
|
||||||
|
* IM_YUV_TO_RGB_BT601_LIMIT
|
||||||
|
* IM_YUV_TO_RGB_BT601_FULL
|
||||||
|
* IM_YUV_TO_RGB_BT709_LIMIT
|
||||||
|
* IM_RGB_TO_YUV_BT601_FULL
|
||||||
|
* IM_RGB_TO_YUV_BT601_LIMIT
|
||||||
|
* IM_RGB_TO_YUV_BT709_LIMIT
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcvtcolor(rga_buffer_t src, rga_buffer_t dst, int sfmt, int dfmt, int mode = IM_COLOR_SPACE_DEFAULT, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rotation
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rotation
|
||||||
|
* IM_HAL_TRANSFORM_ROT_90
|
||||||
|
* IM_HAL_TRANSFORM_ROT_180
|
||||||
|
* IM_HAL_TRANSFORM_ROT_270
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imrotate(const rga_buffer_t src, rga_buffer_t dst, int rotation, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flip
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param mode
|
||||||
|
* IM_HAL_TRANSFORM_FLIP_H
|
||||||
|
* IM_HAL_TRANSFORM_FLIP_V
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imflip(const rga_buffer_t src, rga_buffer_t dst, int mode, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2-channel blend (SRC + DST -> DST or SRCA + SRCB -> DST)
|
||||||
|
*
|
||||||
|
* @param fg_image
|
||||||
|
* The foreground image.
|
||||||
|
* @param bg_image
|
||||||
|
* The background image, which is also the output destination image.
|
||||||
|
* @param mode
|
||||||
|
* Port-Duff mode:
|
||||||
|
* IM_ALPHA_BLEND_SRC
|
||||||
|
* IM_ALPHA_BLEND_DST
|
||||||
|
* IM_ALPHA_BLEND_SRC_OVER
|
||||||
|
* IM_ALPHA_BLEND_DST_OVER
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imblend(const rga_buffer_t fd_image, rga_buffer_t bg_image, int mode = IM_ALPHA_BLEND_SRC_OVER, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 3-channel blend (SRC + DST -> DST or SRCA + SRCB -> DST)
|
||||||
|
*
|
||||||
|
* @param fg_image
|
||||||
|
* The foreground image.
|
||||||
|
* @param bg_image
|
||||||
|
* The background image.
|
||||||
|
* @param output_image
|
||||||
|
* The output destination image.
|
||||||
|
* @param mode
|
||||||
|
* Port-Duff mode:
|
||||||
|
* IM_ALPHA_BLEND_SRC
|
||||||
|
* IM_ALPHA_BLEND_DST
|
||||||
|
* IM_ALPHA_BLEND_SRC_OVER
|
||||||
|
* IM_ALPHA_BLEND_DST_OVER
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
* @param release_fence_fd
|
||||||
|
* When 'sync == 0', the fence_fd used to identify the current job state
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcomposite(const rga_buffer_t srcA, const rga_buffer_t srcB, rga_buffer_t dst, int mode = IM_ALPHA_BLEND_SRC_OVER, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* color key
|
||||||
|
*
|
||||||
|
* @param fg_image
|
||||||
|
* The foreground image.
|
||||||
|
* @param bg_image
|
||||||
|
* The background image, which is also the output destination image.
|
||||||
|
* @param colorkey_range
|
||||||
|
* The range of color key.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcolorkey(const rga_buffer_t src, rga_buffer_t dst, im_colorkey_range range, int mode = IM_ALPHA_COLORKEY_NORMAL, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OSD
|
||||||
|
*
|
||||||
|
* @param osd
|
||||||
|
* The osd text block.
|
||||||
|
* @param dst
|
||||||
|
* The background image.
|
||||||
|
* @param osd_rect
|
||||||
|
* The rectangle on the source image that needs to be OSD.
|
||||||
|
* @param osd_config
|
||||||
|
* osd mode configuration.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imosd(const rga_buffer_t osd,const rga_buffer_t dst,
|
||||||
|
const im_rect osd_rect, im_osd_t *osd_config,
|
||||||
|
int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nn quantize
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param nninfo
|
||||||
|
* nn configuration
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imquantize(const rga_buffer_t src, rga_buffer_t dst, im_nn_t nn_info, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROP
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rop_code
|
||||||
|
* The ROP opcode.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imrop(const rga_buffer_t src, rga_buffer_t dst, int rop_code, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill/reset/draw
|
||||||
|
*
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect
|
||||||
|
* The rectangle on the source image that needs to be filled with color.
|
||||||
|
* @param color
|
||||||
|
* The fill color value.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imfill(rga_buffer_t dst, im_rect rect, int color, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill array
|
||||||
|
*
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect_array
|
||||||
|
* The rectangle arrays on the source image that needs to be filled with color.
|
||||||
|
* @param array_size
|
||||||
|
* The size of rectangular area arrays.
|
||||||
|
* @param color
|
||||||
|
* The fill color value.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imfillArray(rga_buffer_t dst, im_rect *rect_array, int array_size, uint32_t color, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill rectangle
|
||||||
|
*
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect
|
||||||
|
* The rectangle on the source image that needs to be filled with color.
|
||||||
|
* @param color
|
||||||
|
* The fill color value.
|
||||||
|
* @param thickness
|
||||||
|
* Thickness of lines that make up the rectangle. Negative values, like -1,
|
||||||
|
* mean that the function has to draw a filled rectangle.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imrectangle(rga_buffer_t dst, im_rect rect,
|
||||||
|
uint32_t color, int thickness,
|
||||||
|
int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill rectangle array
|
||||||
|
*
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect_array
|
||||||
|
* The rectangle arrays on the source image that needs to be filled with color.
|
||||||
|
* @param array_size
|
||||||
|
* The size of rectangular area arrays.
|
||||||
|
* @param color
|
||||||
|
* The fill color value.
|
||||||
|
* @param thickness
|
||||||
|
* Thickness of lines that make up the rectangle. Negative values, like -1,
|
||||||
|
* mean that the function has to draw a filled rectangle.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imrectangleArray(rga_buffer_t dst, im_rect *rect_array, int array_size,
|
||||||
|
uint32_t color, int thickness,
|
||||||
|
int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MOSAIC
|
||||||
|
*
|
||||||
|
* @param image
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect
|
||||||
|
* The rectangle on the source image that needs to be mosaicked.
|
||||||
|
* @param mosaic_mode
|
||||||
|
* mosaic block width configuration:
|
||||||
|
* IM_MOSAIC_8
|
||||||
|
* IM_MOSAIC_16
|
||||||
|
* IM_MOSAIC_32
|
||||||
|
* IM_MOSAIC_64
|
||||||
|
* IM_MOSAIC_128
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS immosaic(const rga_buffer_t image, im_rect rect, int mosaic_mode, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MOSAIC array
|
||||||
|
*
|
||||||
|
* @param image
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect_array
|
||||||
|
* The rectangle arrays on the source image that needs to be filled with color.
|
||||||
|
* @param array_size
|
||||||
|
* The size of rectangular area arrays.
|
||||||
|
* @param mosaic_mode
|
||||||
|
* mosaic block width configuration:
|
||||||
|
* IM_MOSAIC_8
|
||||||
|
* IM_MOSAIC_16
|
||||||
|
* IM_MOSAIC_32
|
||||||
|
* IM_MOSAIC_64
|
||||||
|
* IM_MOSAIC_128
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS immosaicArray(const rga_buffer_t image, im_rect *rect_array, int array_size, int mosaic_mode, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* palette
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param lut
|
||||||
|
* The LUT table.
|
||||||
|
* @param sync
|
||||||
|
* When 'sync == 1', wait for the operation to complete and return, otherwise return directly.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS impalette(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t lut, int sync = 1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* process for single task mode
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image and is also the foreground image in blend.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image and is also the foreground image in blend.
|
||||||
|
* @param pat
|
||||||
|
* The foreground image, or a LUT table.
|
||||||
|
* @param srect
|
||||||
|
* The rectangle on the src channel image that needs to be processed.
|
||||||
|
* @param drect
|
||||||
|
* The rectangle on the dst channel image that needs to be processed.
|
||||||
|
* @param prect
|
||||||
|
* The rectangle on the pat channel image that needs to be processed.
|
||||||
|
* @param opt
|
||||||
|
* The image processing options configuration.
|
||||||
|
* @param usage
|
||||||
|
* The image processing usage.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS improcess(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
|
||||||
|
im_rect srect, im_rect drect, im_rect prect,
|
||||||
|
int acquire_fence_fd, int *release_fence_fd,
|
||||||
|
im_opt_t *opt_ptr, int usage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make border
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param top
|
||||||
|
* the top pixels
|
||||||
|
* @param bottom
|
||||||
|
* the bottom pixels
|
||||||
|
* @param left
|
||||||
|
* the left pixels
|
||||||
|
* @param right
|
||||||
|
* the right pixels
|
||||||
|
* @param border_type
|
||||||
|
* Border type.
|
||||||
|
* @param value
|
||||||
|
* The pixel value at which the border is filled.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS immakeBorder(rga_buffer_t src, rga_buffer_t dst,
|
||||||
|
int top, int bottom, int left, int right,
|
||||||
|
int border_type, int value = 0,
|
||||||
|
int sync = 1, int acquir_fence_fd = -1, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
#endif /* #ifdef __cplusplus */
|
||||||
|
|
||||||
|
IM_C_API IM_STATUS immosaic(const rga_buffer_t image, im_rect rect, int mosaic_mode, int sync);
|
||||||
|
IM_C_API IM_STATUS imosd(const rga_buffer_t osd,const rga_buffer_t dst,
|
||||||
|
const im_rect osd_rect, im_osd_t *osd_config, int sync);
|
||||||
|
IM_C_API IM_STATUS improcess(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
|
||||||
|
im_rect srect, im_rect drect, im_rect prect, int usage);
|
||||||
|
|
||||||
|
/* Start: Symbols reserved for compatibility with macro functions */
|
||||||
|
IM_C_API IM_STATUS imcopy_t(const rga_buffer_t src, rga_buffer_t dst, int sync);
|
||||||
|
IM_C_API IM_STATUS imresize_t(const rga_buffer_t src, rga_buffer_t dst, double fx, double fy, int interpolation, int sync);
|
||||||
|
IM_C_API IM_STATUS imcrop_t(const rga_buffer_t src, rga_buffer_t dst, im_rect rect, int sync);
|
||||||
|
IM_C_API IM_STATUS imtranslate_t(const rga_buffer_t src, rga_buffer_t dst, int x, int y, int sync);
|
||||||
|
IM_C_API IM_STATUS imcvtcolor_t(rga_buffer_t src, rga_buffer_t dst, int sfmt, int dfmt, int mode, int sync);
|
||||||
|
IM_C_API IM_STATUS imrotate_t(const rga_buffer_t src, rga_buffer_t dst, int rotation, int sync);
|
||||||
|
IM_C_API IM_STATUS imflip_t (const rga_buffer_t src, rga_buffer_t dst, int mode, int sync);
|
||||||
|
IM_C_API IM_STATUS imblend_t(const rga_buffer_t srcA, const rga_buffer_t srcB, rga_buffer_t dst, int mode, int sync);
|
||||||
|
IM_C_API IM_STATUS imcolorkey_t(const rga_buffer_t src, rga_buffer_t dst, im_colorkey_range range, int mode, int sync);
|
||||||
|
IM_C_API IM_STATUS imquantize_t(const rga_buffer_t src, rga_buffer_t dst, im_nn_t nn_info, int sync);
|
||||||
|
IM_C_API IM_STATUS imrop_t(const rga_buffer_t src, rga_buffer_t dst, int rop_code, int sync);
|
||||||
|
IM_C_API IM_STATUS imfill_t(rga_buffer_t dst, im_rect rect, int color, int sync);
|
||||||
|
IM_C_API IM_STATUS impalette_t(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t lut, int sync);
|
||||||
|
/* End: Symbols reserved for compatibility with macro functions */
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
|
#define RGA_GET_MIN(n1, n2) ((n1) < (n2) ? (n1) : (n2))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copy
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imcopy(src, dst, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imcopy_t(src, dst, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imcopy_t(src, dst, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resize
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param fx
|
||||||
|
* @param fy
|
||||||
|
* @param interpolation
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imresize(src, dst, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
double __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(double); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imresize_t(src, dst, 0, 0, INTER_LINEAR, 1); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
__ret = imresize_t(src, dst, __args[RGA_GET_MIN(__argc, 0)], __args[RGA_GET_MIN(__argc, 1)], INTER_LINEAR, 1); \
|
||||||
|
} else if (__argc == 3){ \
|
||||||
|
__ret = imresize_t(src, dst, __args[RGA_GET_MIN(__argc, 0)], __args[RGA_GET_MIN(__argc, 1)], (int)__args[RGA_GET_MIN(__argc, 2)], 1); \
|
||||||
|
} else if (__argc == 4){ \
|
||||||
|
__ret = imresize_t(src, dst, __args[RGA_GET_MIN(__argc, 0)], __args[RGA_GET_MIN(__argc, 1)], (int)__args[RGA_GET_MIN(__argc, 2)], (int)__args[RGA_GET_MIN(__argc, 3)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define impyramid(src, dst, direction) \
|
||||||
|
imresize_t(src, \
|
||||||
|
dst, \
|
||||||
|
direction == IM_UP_SCALE ? 0.5 : 2, \
|
||||||
|
direction == IM_UP_SCALE ? 0.5 : 2, \
|
||||||
|
INTER_LINEAR, 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* format convert
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param sfmt
|
||||||
|
* @param dfmt
|
||||||
|
* @param mode
|
||||||
|
* color space mode: IM_COLOR_SPACE_MODE
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imcvtcolor(src, dst, sfmt, dfmt, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imcvtcolor_t(src, dst, sfmt, dfmt, IM_COLOR_SPACE_DEFAULT, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imcvtcolor_t(src, dst, sfmt, dfmt, (int)__args[RGA_GET_MIN(__argc, 0)], 1); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
__ret = imcvtcolor_t(src, dst, sfmt, dfmt, (int)__args[RGA_GET_MIN(__argc, 0)], (int)__args[RGA_GET_MIN(__argc, 1)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crop
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param rect
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imcrop(src, dst, rect, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imcrop_t(src, dst, rect, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imcrop_t(src, dst, rect, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* translate
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imtranslate(src, dst, x, y, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imtranslate_t(src, dst, x, y, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imtranslate_t(src, dst, x, y, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rotation
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param rotation
|
||||||
|
* IM_HAL_TRANSFORM_ROT_90
|
||||||
|
* IM_HAL_TRANSFORM_ROT_180
|
||||||
|
* IM_HAL_TRANSFORM_ROT_270
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imrotate(src, dst, rotation, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imrotate_t(src, dst, rotation, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imrotate_t(src, dst, rotation, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flip
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param mode
|
||||||
|
* IM_HAL_TRANSFORM_FLIP_H
|
||||||
|
* IM_HAL_TRANSFORM_FLIP_V
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imflip(src, dst, mode, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imflip_t(src, dst, mode, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imflip_t(src, dst, mode, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* blend (SRC + DST -> DST or SRCA + SRCB -> DST)
|
||||||
|
*
|
||||||
|
* @param srcA
|
||||||
|
* @param srcB can be NULL.
|
||||||
|
* @param dst
|
||||||
|
* @param mode
|
||||||
|
* IM_ALPHA_BLEND_MODE
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imblend(srcA, dst, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
rga_buffer_t srcB; \
|
||||||
|
memset(&srcB, 0x00, sizeof(rga_buffer_t)); \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imblend_t(srcA, srcB, dst, IM_ALPHA_BLEND_SRC_OVER, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imblend_t(srcA, srcB, dst, (int)__args[RGA_GET_MIN(__argc, 0)], 1); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
__ret = imblend_t(srcA, srcB, dst, (int)__args[RGA_GET_MIN(__argc, 0)], (int)__args[RGA_GET_MIN(__argc, 1)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
#define imcomposite(srcA, srcB, dst, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imblend_t(srcA, srcB, dst, IM_ALPHA_BLEND_SRC_OVER, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imblend_t(srcA, srcB, dst, (int)__args[RGA_GET_MIN(__argc, 0)], 1); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
__ret = imblend_t(srcA, srcB, dst, (int)__args[RGA_GET_MIN(__argc, 0)], (int)__args[RGA_GET_MIN(__argc, 1)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* color key
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param colorkey_range
|
||||||
|
* max color
|
||||||
|
* min color
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imcolorkey(src, dst, range, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imcolorkey_t(src, dst, range, IM_ALPHA_COLORKEY_NORMAL, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imcolorkey_t(src, dst, range, (int)__args[RGA_GET_MIN(__argc, 0)], 1); \
|
||||||
|
} else if (__argc == 2){ \
|
||||||
|
__ret = imcolorkey_t(src, dst, range, (int)__args[RGA_GET_MIN(__argc, 0)], (int)__args[RGA_GET_MIN(__argc, 1)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nn quantize
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param nninfo
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imquantize(src, dst, nn_info, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imquantize_t(src, dst, nn_info, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imquantize_t(src, dst, nn_info, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROP
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param rop_code
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imrop(src, dst, rop_code, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imrop_t(src, dst, rop_code, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imrop_t(src, dst, rop_code, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill/reset/draw
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param rect
|
||||||
|
* @param color
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define imfill(buf, rect, color, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imfill_t(buf, rect, color, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imfill_t(buf, rect, color, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define imreset(buf, rect, color, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imfill_t(buf, rect, color, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imfill_t(buf, rect, color, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define imdraw(buf, rect, color, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = imfill_t(buf, rect, color, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = imfill_t(buf, rect, color, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* palette
|
||||||
|
*
|
||||||
|
* @param src
|
||||||
|
* @param dst
|
||||||
|
* @param lut
|
||||||
|
* @param sync
|
||||||
|
* wait until operation complete
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
#define impalette(src, dst, lut, ...) \
|
||||||
|
({ \
|
||||||
|
IM_STATUS __ret = IM_STATUS_SUCCESS; \
|
||||||
|
int __args[] = {__VA_ARGS__}; \
|
||||||
|
int __argc = sizeof(__args)/sizeof(int); \
|
||||||
|
if (__argc == 0) { \
|
||||||
|
__ret = impalette_t(src, dst, lut, 1); \
|
||||||
|
} else if (__argc == 1){ \
|
||||||
|
__ret = impalette_t(src, dst, lut, (int)__args[RGA_GET_MIN(__argc, 0)]); \
|
||||||
|
} else { \
|
||||||
|
__ret = IM_STATUS_INVALID_PARAM; \
|
||||||
|
printf("invalid parameter\n"); \
|
||||||
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
/* End define IM2D macro API */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* #ifndef _im2d_single_h_ */
|
497
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_task.h
vendored
Normal file
497
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_task.h
vendored
Normal file
|
@ -0,0 +1,497 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _im2d_task_h_
|
||||||
|
#define _im2d_task_h_
|
||||||
|
|
||||||
|
#include "im2d_type.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an rga job
|
||||||
|
*
|
||||||
|
* @param flags
|
||||||
|
* Some configuration flags for this job
|
||||||
|
*
|
||||||
|
* @returns job handle.
|
||||||
|
*/
|
||||||
|
IM_API im_job_handle_t imbeginJob(uint64_t flags = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submit and run an rga job
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* This is the job handle that will be submitted.
|
||||||
|
* @param sync_mode
|
||||||
|
* run mode:
|
||||||
|
* IM_SYNC
|
||||||
|
* IM_ASYNC
|
||||||
|
* @param acquire_fence_fd
|
||||||
|
* @param release_fence_fd
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imendJob(im_job_handle_t job_handle,
|
||||||
|
int sync_mode = IM_SYNC,
|
||||||
|
int acquire_fence_fd = 0, int *release_fence_fd = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel and delete an rga job
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* This is the job handle that will be cancelled.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcancelJob(im_job_handle_t job_handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add copy task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcopyTask(im_job_handle_t job_handle, const rga_buffer_t src, rga_buffer_t dst);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add resize task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param fx
|
||||||
|
* X-direction resize factor.
|
||||||
|
* @param fy
|
||||||
|
* X-direction resize factor.
|
||||||
|
* @param interpolation
|
||||||
|
* Interpolation formula(Only RGA1 support).
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imresizeTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t src, rga_buffer_t dst,
|
||||||
|
double fx = 0, double fy = 0,
|
||||||
|
int interpolation = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add crop task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect
|
||||||
|
* The rectangle on the source image that needs to be cropped.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcropTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t src, rga_buffer_t dst, im_rect rect);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add translate task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param x
|
||||||
|
* Output the coordinates of the starting point in the X-direction of the destination image.
|
||||||
|
* @param y
|
||||||
|
* Output the coordinates of the starting point in the Y-direction of the destination image.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imtranslateTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t src, rga_buffer_t dst, int x, int y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add format convert task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param sfmt
|
||||||
|
* The source image format.
|
||||||
|
* @param dfmt
|
||||||
|
* The destination image format.
|
||||||
|
* @param mode
|
||||||
|
* color space mode:
|
||||||
|
* IM_YUV_TO_RGB_BT601_LIMIT
|
||||||
|
* IM_YUV_TO_RGB_BT601_FULL
|
||||||
|
* IM_YUV_TO_RGB_BT709_LIMIT
|
||||||
|
* IM_RGB_TO_YUV_BT601_FULL
|
||||||
|
* IM_RGB_TO_YUV_BT601_LIMIT
|
||||||
|
* IM_RGB_TO_YUV_BT709_LIMIT
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcvtcolorTask(im_job_handle_t job_handle,
|
||||||
|
rga_buffer_t src, rga_buffer_t dst,
|
||||||
|
int sfmt, int dfmt, int mode = IM_COLOR_SPACE_DEFAULT);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add rotation task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rotation
|
||||||
|
* IM_HAL_TRANSFORM_ROT_90
|
||||||
|
* IM_HAL_TRANSFORM_ROT_180
|
||||||
|
* IM_HAL_TRANSFORM_ROT_270
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imrotateTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t src, rga_buffer_t dst, int rotation);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add flip task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param mode
|
||||||
|
* IM_HAL_TRANSFORM_FLIP_H
|
||||||
|
* IM_HAL_TRANSFORM_FLIP_V
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imflipTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t src, rga_buffer_t dst, int mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add blend(SRC + DST -> DST) task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param fg_image
|
||||||
|
* The foreground image.
|
||||||
|
* @param bg_image
|
||||||
|
* The background image, which is also the output destination image.
|
||||||
|
* @param mode
|
||||||
|
* Port-Duff mode:
|
||||||
|
* IM_ALPHA_BLEND_SRC
|
||||||
|
* IM_ALPHA_BLEND_DST
|
||||||
|
* IM_ALPHA_BLEND_SRC_OVER
|
||||||
|
* IM_ALPHA_BLEND_DST_OVER
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imblendTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t fg_image, rga_buffer_t bg_image,
|
||||||
|
int mode = IM_ALPHA_BLEND_SRC_OVER);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add composite(SRCA + SRCB -> DST) task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param fg_image
|
||||||
|
* The foreground image.
|
||||||
|
* @param bg_image
|
||||||
|
* The background image.
|
||||||
|
* @param output_image
|
||||||
|
* The output destination image.
|
||||||
|
* @param mode
|
||||||
|
* Port-Duff mode:
|
||||||
|
* IM_ALPHA_BLEND_SRC
|
||||||
|
* IM_ALPHA_BLEND_DST
|
||||||
|
* IM_ALPHA_BLEND_SRC_OVER
|
||||||
|
* IM_ALPHA_BLEND_DST_OVER
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcompositeTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t fg_image, const rga_buffer_t bg_image,
|
||||||
|
rga_buffer_t output_image,
|
||||||
|
int mode = IM_ALPHA_BLEND_SRC_OVER);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add color key task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param fg_image
|
||||||
|
* The foreground image.
|
||||||
|
* @param bg_image
|
||||||
|
* The background image, which is also the output destination image.
|
||||||
|
* @param colorkey_range
|
||||||
|
* The range of color key.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imcolorkeyTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t fg_image, rga_buffer_t bg_image,
|
||||||
|
im_colorkey_range range, int mode = IM_ALPHA_COLORKEY_NORMAL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add OSD task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param osd
|
||||||
|
* The osd text block.
|
||||||
|
* @param dst
|
||||||
|
* The background image.
|
||||||
|
* @param osd_rect
|
||||||
|
* The rectangle on the source image that needs to be OSD.
|
||||||
|
* @param osd_config
|
||||||
|
* osd mode configuration.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imosdTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t osd,const rga_buffer_t bg_image,
|
||||||
|
const im_rect osd_rect, im_osd_t *osd_config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add nn quantize task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param nninfo
|
||||||
|
* nn configuration
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imquantizeTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t src, rga_buffer_t dst, im_nn_t nn_info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add ROP task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rop_code
|
||||||
|
* The ROP opcode.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imropTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t src, rga_buffer_t dst, int rop_code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add color fill task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect
|
||||||
|
* The rectangle on the source image that needs to be filled with color.
|
||||||
|
* @param color
|
||||||
|
* The fill color value.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imfillTask(im_job_handle_t job_handle, rga_buffer_t dst, im_rect rect, uint32_t color);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add color fill task array
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect_array
|
||||||
|
* The rectangle arrays on the source image that needs to be filled with color.
|
||||||
|
* @param array_size
|
||||||
|
* The size of rectangular area arrays.
|
||||||
|
* @param color
|
||||||
|
* The fill color value.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imfillTaskArray(im_job_handle_t job_handle,
|
||||||
|
rga_buffer_t dst,
|
||||||
|
im_rect *rect_array, int array_size, uint32_t color);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add fill rectangle task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect
|
||||||
|
* The rectangle on the source image that needs to be filled with color.
|
||||||
|
* @param color
|
||||||
|
* The fill color value.
|
||||||
|
* @param thickness
|
||||||
|
* Thickness of lines that make up the rectangle. Negative values, like -1,
|
||||||
|
* mean that the function has to draw a filled rectangle.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imrectangleTask(im_job_handle_t job_handle,
|
||||||
|
rga_buffer_t dst,
|
||||||
|
im_rect rect,
|
||||||
|
uint32_t color, int thickness);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add fill rectangle task array
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect_array
|
||||||
|
* The rectangle arrays on the source image that needs to be filled with color.
|
||||||
|
* @param array_size
|
||||||
|
* The size of rectangular area arrays.
|
||||||
|
* @param color
|
||||||
|
* The fill color value.
|
||||||
|
* @param thickness
|
||||||
|
* Thickness of lines that make up the rectangle. Negative values, like -1,
|
||||||
|
* mean that the function has to draw a filled rectangle.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS imrectangleTaskArray(im_job_handle_t job_handle,
|
||||||
|
rga_buffer_t dst,
|
||||||
|
im_rect *rect_array, int array_size,
|
||||||
|
uint32_t color, int thickness);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add mosaic task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param image
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect
|
||||||
|
* The rectangle on the source image that needs to be mosaicked.
|
||||||
|
* @param mosaic_mode
|
||||||
|
* mosaic block width configuration:
|
||||||
|
* IM_MOSAIC_8
|
||||||
|
* IM_MOSAIC_16
|
||||||
|
* IM_MOSAIC_32
|
||||||
|
* IM_MOSAIC_64
|
||||||
|
* IM_MOSAIC_128
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS immosaicTask(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t image, im_rect rect, int mosaic_mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add mosaic task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param image
|
||||||
|
* The output destination image.
|
||||||
|
* @param rect_array
|
||||||
|
* The rectangle arrays on the source image that needs to be filled with color.
|
||||||
|
* @param array_size
|
||||||
|
* The size of rectangular area arrays.
|
||||||
|
* @param mosaic_mode
|
||||||
|
* mosaic block width configuration:
|
||||||
|
* IM_MOSAIC_8
|
||||||
|
* IM_MOSAIC_16
|
||||||
|
* IM_MOSAIC_32
|
||||||
|
* IM_MOSAIC_64
|
||||||
|
* IM_MOSAIC_128
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS immosaicTaskArray(im_job_handle_t job_handle,
|
||||||
|
const rga_buffer_t image,
|
||||||
|
im_rect *rect_array, int array_size, int mosaic_mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add palette task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image.
|
||||||
|
* @param lut
|
||||||
|
* The LUT table.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS impaletteTask(im_job_handle_t job_handle,
|
||||||
|
rga_buffer_t src, rga_buffer_t dst, rga_buffer_t lut);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add process task
|
||||||
|
*
|
||||||
|
* @param job_handle
|
||||||
|
* Insert the task into the job handle.
|
||||||
|
* @param src
|
||||||
|
* The input source image and is also the foreground image in blend.
|
||||||
|
* @param dst
|
||||||
|
* The output destination image and is also the foreground image in blend.
|
||||||
|
* @param pat
|
||||||
|
* The foreground image, or a LUT table.
|
||||||
|
* @param srect
|
||||||
|
* The rectangle on the src channel image that needs to be processed.
|
||||||
|
* @param drect
|
||||||
|
* The rectangle on the dst channel image that needs to be processed.
|
||||||
|
* @param prect
|
||||||
|
* The rectangle on the pat channel image that needs to be processed.
|
||||||
|
* @param opt
|
||||||
|
* The image processing options configuration.
|
||||||
|
* @param usage
|
||||||
|
* The image processing usage.
|
||||||
|
*
|
||||||
|
* @returns success or else negative error code.
|
||||||
|
*/
|
||||||
|
IM_API IM_STATUS improcessTask(im_job_handle_t job_handle,
|
||||||
|
rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
|
||||||
|
im_rect srect, im_rect drect, im_rect prect,
|
||||||
|
im_opt_t *opt_ptr, int usage);
|
||||||
|
|
||||||
|
#endif /* #ifdef __cplusplus */
|
||||||
|
|
||||||
|
#endif /* #ifndef _im2d_task_h_ */
|
436
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_type.h
vendored
Normal file
436
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_type.h
vendored
Normal file
|
@ -0,0 +1,436 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _RGA_IM2D_TYPE_H_
|
||||||
|
#define _RGA_IM2D_TYPE_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "rga.h"
|
||||||
|
|
||||||
|
#define IM_API /* define API export as needed */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define IM_C_API extern "C"
|
||||||
|
#define IM_EXPORT_API extern "C"
|
||||||
|
#else
|
||||||
|
#define IM_C_API
|
||||||
|
#define IM_EXPORT_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define DEFAULT_INITIALIZER(x) = x
|
||||||
|
#else
|
||||||
|
#define DEFAULT_INITIALIZER(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef uint32_t im_api_version_t;
|
||||||
|
typedef uint32_t im_job_handle_t;
|
||||||
|
typedef uint32_t im_ctx_id_t;
|
||||||
|
typedef uint32_t rga_buffer_handle_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
/* Rotation */
|
||||||
|
IM_HAL_TRANSFORM_ROT_90 = 1 << 0,
|
||||||
|
IM_HAL_TRANSFORM_ROT_180 = 1 << 1,
|
||||||
|
IM_HAL_TRANSFORM_ROT_270 = 1 << 2,
|
||||||
|
IM_HAL_TRANSFORM_FLIP_H = 1 << 3,
|
||||||
|
IM_HAL_TRANSFORM_FLIP_V = 1 << 4,
|
||||||
|
IM_HAL_TRANSFORM_FLIP_H_V = 1 << 5,
|
||||||
|
IM_HAL_TRANSFORM_MASK = 0x3f,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Blend
|
||||||
|
* Additional blend usage, can be used with both source and target configs.
|
||||||
|
* If none of the below is set, the default "SRC over DST" is applied.
|
||||||
|
*/
|
||||||
|
IM_ALPHA_BLEND_SRC_OVER = 1 << 6, /* Default, Porter-Duff "SRC over DST" */
|
||||||
|
IM_ALPHA_BLEND_SRC = 1 << 7, /* Porter-Duff "SRC" */
|
||||||
|
IM_ALPHA_BLEND_DST = 1 << 8, /* Porter-Duff "DST" */
|
||||||
|
IM_ALPHA_BLEND_SRC_IN = 1 << 9, /* Porter-Duff "SRC in DST" */
|
||||||
|
IM_ALPHA_BLEND_DST_IN = 1 << 10, /* Porter-Duff "DST in SRC" */
|
||||||
|
IM_ALPHA_BLEND_SRC_OUT = 1 << 11, /* Porter-Duff "SRC out DST" */
|
||||||
|
IM_ALPHA_BLEND_DST_OUT = 1 << 12, /* Porter-Duff "DST out SRC" */
|
||||||
|
IM_ALPHA_BLEND_DST_OVER = 1 << 13, /* Porter-Duff "DST over SRC" */
|
||||||
|
IM_ALPHA_BLEND_SRC_ATOP = 1 << 14, /* Porter-Duff "SRC ATOP" */
|
||||||
|
IM_ALPHA_BLEND_DST_ATOP = 1 << 15, /* Porter-Duff "DST ATOP" */
|
||||||
|
IM_ALPHA_BLEND_XOR = 1 << 16, /* Xor */
|
||||||
|
IM_ALPHA_BLEND_MASK = 0x1ffc0,
|
||||||
|
|
||||||
|
IM_ALPHA_COLORKEY_NORMAL = 1 << 17,
|
||||||
|
IM_ALPHA_COLORKEY_INVERTED = 1 << 18,
|
||||||
|
IM_ALPHA_COLORKEY_MASK = 0x60000,
|
||||||
|
|
||||||
|
IM_SYNC = 1 << 19,
|
||||||
|
IM_CROP = 1 << 20, /* Unused */
|
||||||
|
IM_COLOR_FILL = 1 << 21,
|
||||||
|
IM_COLOR_PALETTE = 1 << 22,
|
||||||
|
IM_NN_QUANTIZE = 1 << 23,
|
||||||
|
IM_ROP = 1 << 24,
|
||||||
|
IM_ALPHA_BLEND_PRE_MUL = 1 << 25,
|
||||||
|
IM_ASYNC = 1 << 26,
|
||||||
|
IM_MOSAIC = 1 << 27,
|
||||||
|
IM_OSD = 1 << 28,
|
||||||
|
IM_PRE_INTR = 1 << 29,
|
||||||
|
} IM_USAGE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_RASTER_MODE = 1 << 0,
|
||||||
|
IM_FBC_MODE = 1 << 1,
|
||||||
|
IM_TILE_MODE = 1 << 2,
|
||||||
|
} IM_RD_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_SCHEDULER_RGA3_CORE0 = 1 << 0,
|
||||||
|
IM_SCHEDULER_RGA3_CORE1 = 1 << 1,
|
||||||
|
IM_SCHEDULER_RGA2_CORE0 = 1 << 2,
|
||||||
|
IM_SCHEDULER_RGA3_DEFAULT = IM_SCHEDULER_RGA3_CORE0,
|
||||||
|
IM_SCHEDULER_RGA2_DEFAULT = IM_SCHEDULER_RGA2_CORE0,
|
||||||
|
IM_SCHEDULER_MASK = 0x7,
|
||||||
|
IM_SCHEDULER_DEFAULT = 0,
|
||||||
|
} IM_SCHEDULER_CORE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_ROP_AND = 0x88,
|
||||||
|
IM_ROP_OR = 0xee,
|
||||||
|
IM_ROP_NOT_DST = 0x55,
|
||||||
|
IM_ROP_NOT_SRC = 0x33,
|
||||||
|
IM_ROP_XOR = 0xf6,
|
||||||
|
IM_ROP_NOT_XOR = 0xf9,
|
||||||
|
} IM_ROP_CODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_MOSAIC_8 = 0x0,
|
||||||
|
IM_MOSAIC_16 = 0x1,
|
||||||
|
IM_MOSAIC_32 = 0x2,
|
||||||
|
IM_MOSAIC_64 = 0x3,
|
||||||
|
IM_MOSAIC_128 = 0x4,
|
||||||
|
} IM_MOSAIC_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_BORDER_CONSTANT = 0, /* iiiiii|abcdefgh|iiiiiii with some specified value 'i' */
|
||||||
|
IM_BORDER_REFLECT = 2, /* fedcba|abcdefgh|hgfedcb */
|
||||||
|
IM_BORDER_WRAP = 3, /* cdefgh|abcdefgh|abcdefg */
|
||||||
|
} IM_BORDER_TYPE;
|
||||||
|
|
||||||
|
/* Status codes, returned by any blit function */
|
||||||
|
typedef enum {
|
||||||
|
IM_YUV_TO_RGB_BT601_LIMIT = 1 << 0,
|
||||||
|
IM_YUV_TO_RGB_BT601_FULL = 2 << 0,
|
||||||
|
IM_YUV_TO_RGB_BT709_LIMIT = 3 << 0,
|
||||||
|
IM_YUV_TO_RGB_MASK = 3 << 0,
|
||||||
|
IM_RGB_TO_YUV_BT601_FULL = 1 << 2,
|
||||||
|
IM_RGB_TO_YUV_BT601_LIMIT = 2 << 2,
|
||||||
|
IM_RGB_TO_YUV_BT709_LIMIT = 3 << 2,
|
||||||
|
IM_RGB_TO_YUV_MASK = 3 << 2,
|
||||||
|
IM_RGB_TO_Y4 = 1 << 4,
|
||||||
|
IM_RGB_TO_Y4_DITHER = 2 << 4,
|
||||||
|
IM_RGB_TO_Y1_DITHER = 3 << 4,
|
||||||
|
IM_Y4_MASK = 3 << 4,
|
||||||
|
IM_RGB_FULL = 1 << 8,
|
||||||
|
IM_RGB_CLIP = 2 << 8,
|
||||||
|
IM_YUV_BT601_LIMIT_RANGE = 3 << 8,
|
||||||
|
IM_YUV_BT601_FULL_RANGE = 4 << 8,
|
||||||
|
IM_YUV_BT709_LIMIT_RANGE = 5 << 8,
|
||||||
|
IM_YUV_BT709_FULL_RANGE = 6 << 8,
|
||||||
|
IM_FULL_CSC_MASK = 0xf << 8,
|
||||||
|
IM_COLOR_SPACE_DEFAULT = 0,
|
||||||
|
} IM_COLOR_SPACE_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_UP_SCALE,
|
||||||
|
IM_DOWN_SCALE,
|
||||||
|
} IM_SCALE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
INTER_NEAREST,
|
||||||
|
INTER_LINEAR,
|
||||||
|
INTER_CUBIC,
|
||||||
|
} IM_SCALE_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_CONFIG_SCHEDULER_CORE,
|
||||||
|
IM_CONFIG_PRIORITY,
|
||||||
|
IM_CONFIG_CHECK,
|
||||||
|
} IM_CONFIG_NAME;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_OSD_MODE_STATISTICS = 0x1 << 0,
|
||||||
|
IM_OSD_MODE_AUTO_INVERT = 0x1 << 1,
|
||||||
|
} IM_OSD_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_OSD_INVERT_CHANNEL_NONE = 0x0,
|
||||||
|
IM_OSD_INVERT_CHANNEL_Y_G = 0x1 << 0,
|
||||||
|
IM_OSD_INVERT_CHANNEL_C_RB = 0x1 << 1,
|
||||||
|
IM_OSD_INVERT_CHANNEL_ALPHA = 0x1 << 2,
|
||||||
|
IM_OSD_INVERT_CHANNEL_COLOR = IM_OSD_INVERT_CHANNEL_Y_G |
|
||||||
|
IM_OSD_INVERT_CHANNEL_C_RB,
|
||||||
|
IM_OSD_INVERT_CHANNEL_BOTH = IM_OSD_INVERT_CHANNEL_COLOR |
|
||||||
|
IM_OSD_INVERT_CHANNEL_ALPHA,
|
||||||
|
} IM_OSD_INVERT_CHANNEL;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_OSD_FLAGS_INTERNAL = 0,
|
||||||
|
IM_OSD_FLAGS_EXTERNAL,
|
||||||
|
} IM_OSD_FLAGS_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_OSD_INVERT_USE_FACTOR,
|
||||||
|
IM_OSD_INVERT_USE_SWAP,
|
||||||
|
} IM_OSD_INVERT_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_OSD_BACKGROUND_DEFAULT_BRIGHT = 0,
|
||||||
|
IM_OSD_BACKGROUND_DEFAULT_DARK,
|
||||||
|
} IM_OSD_BACKGROUND_DEFAULT;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_OSD_BLOCK_MODE_NORMAL = 0,
|
||||||
|
IM_OSD_BLOCK_MODE_DIFFERENT,
|
||||||
|
} IM_OSD_BLOCK_WIDTH_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_OSD_MODE_HORIZONTAL,
|
||||||
|
IM_OSD_MODE_VERTICAL,
|
||||||
|
} IM_OSD_DIRECTION;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_OSD_COLOR_PIXEL,
|
||||||
|
IM_OSD_COLOR_EXTERNAL,
|
||||||
|
} IM_OSD_COLOR_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_INTR_READ_INTR = 1 << 0,
|
||||||
|
IM_INTR_READ_HOLD = 1 << 1,
|
||||||
|
IM_INTR_WRITE_INTR = 1 << 2,
|
||||||
|
} IM_PRE_INTR_FLAGS;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IM_CONTEXT_NONE = 0x0,
|
||||||
|
IM_CONTEXT_SRC_FIX_ENABLE = 0x1 << 0, // Enable kernel to modify the image parameters of the channel.
|
||||||
|
IM_CONTEXT_SRC_CACHE_INFO = 0x1 << 1, // It will replace the parameters in ctx with the modified parameters.
|
||||||
|
IM_CONTEXT_SRC1_FIX_ENABLE = 0x1 << 2,
|
||||||
|
IM_CONTEXT_SRC1_CACHE_INFO = 0x1 << 3,
|
||||||
|
IM_CONTEXT_DST_FIX_ENABLE = 0x1 << 4,
|
||||||
|
IM_CONTEXT_DST_CACHE_INFO = 0x1 << 5,
|
||||||
|
} IM_CONTEXT_FLAGS;
|
||||||
|
|
||||||
|
/* Get RGA basic information index */
|
||||||
|
typedef enum {
|
||||||
|
RGA_VENDOR = 0,
|
||||||
|
RGA_VERSION,
|
||||||
|
RGA_MAX_INPUT,
|
||||||
|
RGA_MAX_OUTPUT,
|
||||||
|
RGA_BYTE_STRIDE,
|
||||||
|
RGA_SCALE_LIMIT,
|
||||||
|
RGA_INPUT_FORMAT,
|
||||||
|
RGA_OUTPUT_FORMAT,
|
||||||
|
RGA_FEATURE,
|
||||||
|
RGA_EXPECTED,
|
||||||
|
RGA_ALL,
|
||||||
|
} IM_INFORMATION;
|
||||||
|
|
||||||
|
/* Status codes, returned by any blit function */
|
||||||
|
typedef enum {
|
||||||
|
IM_STATUS_NOERROR = 2,
|
||||||
|
IM_STATUS_SUCCESS = 1,
|
||||||
|
IM_STATUS_NOT_SUPPORTED = -1,
|
||||||
|
IM_STATUS_OUT_OF_MEMORY = -2,
|
||||||
|
IM_STATUS_INVALID_PARAM = -3,
|
||||||
|
IM_STATUS_ILLEGAL_PARAM = -4,
|
||||||
|
IM_STATUS_ERROR_VERSION = -5,
|
||||||
|
IM_STATUS_FAILED = 0,
|
||||||
|
} IM_STATUS;
|
||||||
|
|
||||||
|
/* Rectangle definition */
|
||||||
|
typedef struct {
|
||||||
|
int x; /* upper-left x */
|
||||||
|
int y; /* upper-left y */
|
||||||
|
int width; /* width */
|
||||||
|
int height; /* height */
|
||||||
|
} im_rect;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int max; /* The Maximum value of the color key */
|
||||||
|
int min; /* The minimum value of the color key */
|
||||||
|
} im_colorkey_range;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct im_nn {
|
||||||
|
int scale_r; /* scaling factor on R channal */
|
||||||
|
int scale_g; /* scaling factor on G channal */
|
||||||
|
int scale_b; /* scaling factor on B channal */
|
||||||
|
int offset_r; /* offset on R channal */
|
||||||
|
int offset_g; /* offset on G channal */
|
||||||
|
int offset_b; /* offset on B channal */
|
||||||
|
} im_nn_t;
|
||||||
|
|
||||||
|
/* im_info definition */
|
||||||
|
typedef struct {
|
||||||
|
void* vir_addr; /* virtual address */
|
||||||
|
void* phy_addr; /* physical address */
|
||||||
|
int fd; /* shared fd */
|
||||||
|
|
||||||
|
int width; /* width */
|
||||||
|
int height; /* height */
|
||||||
|
int wstride; /* wstride */
|
||||||
|
int hstride; /* hstride */
|
||||||
|
int format; /* format */
|
||||||
|
|
||||||
|
int color_space_mode; /* color_space_mode */
|
||||||
|
int global_alpha; /* global_alpha */
|
||||||
|
int rd_mode;
|
||||||
|
|
||||||
|
/* legarcy */
|
||||||
|
int color; /* color, used by color fill */
|
||||||
|
im_colorkey_range colorkey_range; /* range value of color key */
|
||||||
|
im_nn_t nn;
|
||||||
|
int rop_code;
|
||||||
|
|
||||||
|
rga_buffer_handle_t handle; /* buffer handle */
|
||||||
|
} rga_buffer_t;
|
||||||
|
|
||||||
|
typedef struct im_color {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint8_t red;
|
||||||
|
uint8_t green;
|
||||||
|
uint8_t blue;
|
||||||
|
uint8_t alpha;
|
||||||
|
};
|
||||||
|
uint32_t value;
|
||||||
|
};
|
||||||
|
} im_color_t;
|
||||||
|
|
||||||
|
typedef struct im_osd_invert_factor {
|
||||||
|
uint8_t alpha_max;
|
||||||
|
uint8_t alpha_min;
|
||||||
|
uint8_t yg_max;
|
||||||
|
uint8_t yg_min;
|
||||||
|
uint8_t crb_max;
|
||||||
|
uint8_t crb_min;
|
||||||
|
} im_osd_invert_factor_t;
|
||||||
|
|
||||||
|
typedef struct im_osd_bpp2 {
|
||||||
|
uint8_t ac_swap; // ac swap flag
|
||||||
|
// 0: CA
|
||||||
|
// 1: AC
|
||||||
|
uint8_t endian_swap; // rgba2bpp endian swap
|
||||||
|
// 0: Big endian
|
||||||
|
// 1: Little endian
|
||||||
|
im_color_t color0;
|
||||||
|
im_color_t color1;
|
||||||
|
} im_osd_bpp2_t;
|
||||||
|
|
||||||
|
typedef struct im_osd_block {
|
||||||
|
int width_mode; // normal or different
|
||||||
|
// IM_OSD_BLOCK_MODE_NORMAL
|
||||||
|
// IM_OSD_BLOCK_MODE_DIFFERENT
|
||||||
|
union {
|
||||||
|
int width; // normal_mode block width
|
||||||
|
int width_index; // different_mode block width index in RAM
|
||||||
|
};
|
||||||
|
|
||||||
|
int block_count; // block count
|
||||||
|
|
||||||
|
int background_config; // background config is bright or dark
|
||||||
|
// IM_OSD_BACKGROUND_DEFAULT_BRIGHT
|
||||||
|
// IM_OSD_BACKGROUND_DEFAULT_DARK
|
||||||
|
|
||||||
|
int direction; // osd block direction
|
||||||
|
// IM_OSD_MODE_HORIZONTAL
|
||||||
|
// IM_OSD_MODE_VERTICAL
|
||||||
|
|
||||||
|
int color_mode; // using src1 color or config color
|
||||||
|
// IM_OSD_COLOR_PIXEL
|
||||||
|
// IM_OSD_COLOR_EXTERNAL
|
||||||
|
im_color_t normal_color; // config color: normal
|
||||||
|
im_color_t invert_color; // config color: invert
|
||||||
|
} im_osd_block_t;
|
||||||
|
|
||||||
|
typedef struct im_osd_invert {
|
||||||
|
int invert_channel; // invert channel config:
|
||||||
|
// IM_OSD_INVERT_CHANNEL_NONE
|
||||||
|
// IM_OSD_INVERT_CHANNEL_Y_G
|
||||||
|
// IM_OSD_INVERT_CHANNEL_C_RB
|
||||||
|
// IM_OSD_INVERT_CHANNEL_ALPHA
|
||||||
|
// IM_OSD_INVERT_CHANNEL_COLOR
|
||||||
|
// IM_OSD_INVERT_CHANNEL_BOTH
|
||||||
|
int flags_mode; // use external or inertnal RAM invert flags
|
||||||
|
// IM_OSD_FLAGS_EXTERNAL
|
||||||
|
// IM_OSD_FLAGS_INTERNAL
|
||||||
|
int flags_index; // flags index when using internal RAM invert flags
|
||||||
|
|
||||||
|
uint64_t invert_flags; // external invert flags
|
||||||
|
uint64_t current_flags; // current flags
|
||||||
|
|
||||||
|
int invert_mode; // invert use swap or factor
|
||||||
|
// IM_OSD_INVERT_USE_FACTOR
|
||||||
|
// IM_OSD_INVERT_USE_SWAP
|
||||||
|
im_osd_invert_factor_t factor;
|
||||||
|
|
||||||
|
int threash;
|
||||||
|
} im_osd_invert_t;
|
||||||
|
|
||||||
|
typedef struct im_osd {
|
||||||
|
int osd_mode; // osd mode: statistics or auto_invert
|
||||||
|
// IM_OSD_MODE_STATISTICS
|
||||||
|
// IM_OSD_MODE_AUTO_INVERT
|
||||||
|
im_osd_block_t block_parm; // osd block info config
|
||||||
|
|
||||||
|
im_osd_invert_t invert_config;
|
||||||
|
|
||||||
|
im_osd_bpp2_t bpp2_info;
|
||||||
|
} im_osd_t;
|
||||||
|
|
||||||
|
typedef struct im_intr_config {
|
||||||
|
uint32_t flags;
|
||||||
|
|
||||||
|
int read_threshold;
|
||||||
|
int write_start;
|
||||||
|
int write_step;
|
||||||
|
} im_intr_config_t;
|
||||||
|
|
||||||
|
typedef struct im_opt {
|
||||||
|
im_api_version_t version DEFAULT_INITIALIZER(RGA_CURRENT_API_HEADER_VERSION);
|
||||||
|
|
||||||
|
int color; /* color, used by color fill */
|
||||||
|
im_colorkey_range colorkey_range; /* range value of color key */
|
||||||
|
im_nn_t nn;
|
||||||
|
int rop_code;
|
||||||
|
|
||||||
|
int priority;
|
||||||
|
int core;
|
||||||
|
|
||||||
|
int mosaic_mode;
|
||||||
|
|
||||||
|
im_osd_t osd_config;
|
||||||
|
|
||||||
|
im_intr_config_t intr_config;
|
||||||
|
|
||||||
|
char reserve[128];
|
||||||
|
} im_opt_t;
|
||||||
|
|
||||||
|
typedef struct im_handle_param {
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
uint32_t format;
|
||||||
|
} im_handle_param_t;
|
||||||
|
|
||||||
|
#endif /* _RGA_IM2D_TYPE_H_ */
|
47
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_version.h
vendored
Normal file
47
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/im2d_version.h
vendored
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _RGA_IM2D_VERSION_H_
|
||||||
|
#define _RGA_IM2D_VERSION_H_
|
||||||
|
|
||||||
|
#define RGA_VERSION_STR_HELPER(x) #x
|
||||||
|
#define RGA_VERSION_STR(x) RGA_VERSION_STR_HELPER(x)
|
||||||
|
|
||||||
|
/* RGA im2d api verison */
|
||||||
|
#define RGA_API_MAJOR_VERSION 1
|
||||||
|
#define RGA_API_MINOR_VERSION 9
|
||||||
|
#define RGA_API_REVISION_VERSION 1
|
||||||
|
#define RGA_API_BUILD_VERSION 4
|
||||||
|
|
||||||
|
#define RGA_API_VERSION \
|
||||||
|
RGA_VERSION_STR(RGA_API_MAJOR_VERSION) "." \
|
||||||
|
RGA_VERSION_STR(RGA_API_MINOR_VERSION) "." \
|
||||||
|
RGA_VERSION_STR(RGA_API_REVISION_VERSION) "_[" \
|
||||||
|
RGA_VERSION_STR(RGA_API_BUILD_VERSION) "]"
|
||||||
|
#define RGA_API_FULL_VERSION "rga_api version " RGA_API_VERSION
|
||||||
|
|
||||||
|
/* For header file version verification */
|
||||||
|
#define RGA_CURRENT_API_VERSION (\
|
||||||
|
(RGA_API_MAJOR_VERSION & 0xff) << 24 | \
|
||||||
|
(RGA_API_MINOR_VERSION & 0xff) << 16 | \
|
||||||
|
(RGA_API_REVISION_VERSION & 0xff) << 8 | \
|
||||||
|
(RGA_API_BUILD_VERSION & 0xff)\
|
||||||
|
)
|
||||||
|
#define RGA_CURRENT_API_HEADER_VERSION RGA_CURRENT_API_VERSION
|
||||||
|
|
||||||
|
#endif /* _RGA_IM2D_VERSION_H_ */
|
139
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/rga.h
vendored
Normal file
139
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/include/rga.h
vendored
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||||
|
* Authors:
|
||||||
|
* Zhiqin Wei <wzq@rock-chips.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _RGA_DRIVER_H_
|
||||||
|
#define _RGA_DRIVER_H_
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ENABLE
|
||||||
|
#define ENABLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE
|
||||||
|
#define DISABLE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* In order to be compatible with RK_FORMAT_XX and HAL_PIXEL_FORMAT_XX,
|
||||||
|
* RK_FORMAT_XX is shifted to the left by 8 bits to distinguish. */
|
||||||
|
typedef enum _Rga_SURF_FORMAT {
|
||||||
|
RK_FORMAT_RGBA_8888 = 0x0 << 8,
|
||||||
|
RK_FORMAT_RGBX_8888 = 0x1 << 8,
|
||||||
|
RK_FORMAT_RGB_888 = 0x2 << 8,
|
||||||
|
RK_FORMAT_BGRA_8888 = 0x3 << 8,
|
||||||
|
RK_FORMAT_RGB_565 = 0x4 << 8,
|
||||||
|
RK_FORMAT_RGBA_5551 = 0x5 << 8,
|
||||||
|
RK_FORMAT_RGBA_4444 = 0x6 << 8,
|
||||||
|
RK_FORMAT_BGR_888 = 0x7 << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_YCbCr_422_SP = 0x8 << 8,
|
||||||
|
RK_FORMAT_YCbCr_422_P = 0x9 << 8,
|
||||||
|
RK_FORMAT_YCbCr_420_SP = 0xa << 8,
|
||||||
|
RK_FORMAT_YCbCr_420_P = 0xb << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_YCrCb_422_SP = 0xc << 8,
|
||||||
|
RK_FORMAT_YCrCb_422_P = 0xd << 8,
|
||||||
|
RK_FORMAT_YCrCb_420_SP = 0xe << 8,
|
||||||
|
RK_FORMAT_YCrCb_420_P = 0xf << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_BPP1 = 0x10 << 8,
|
||||||
|
RK_FORMAT_BPP2 = 0x11 << 8,
|
||||||
|
RK_FORMAT_BPP4 = 0x12 << 8,
|
||||||
|
RK_FORMAT_BPP8 = 0x13 << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_Y4 = 0x14 << 8,
|
||||||
|
RK_FORMAT_YCbCr_400 = 0x15 << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_BGRX_8888 = 0x16 << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_YVYU_422 = 0x18 << 8,
|
||||||
|
RK_FORMAT_YVYU_420 = 0x19 << 8,
|
||||||
|
RK_FORMAT_VYUY_422 = 0x1a << 8,
|
||||||
|
RK_FORMAT_VYUY_420 = 0x1b << 8,
|
||||||
|
RK_FORMAT_YUYV_422 = 0x1c << 8,
|
||||||
|
RK_FORMAT_YUYV_420 = 0x1d << 8,
|
||||||
|
RK_FORMAT_UYVY_422 = 0x1e << 8,
|
||||||
|
RK_FORMAT_UYVY_420 = 0x1f << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_YCbCr_420_SP_10B = 0x20 << 8,
|
||||||
|
RK_FORMAT_YCrCb_420_SP_10B = 0x21 << 8,
|
||||||
|
RK_FORMAT_YCbCr_422_SP_10B = 0x22 << 8,
|
||||||
|
RK_FORMAT_YCrCb_422_SP_10B = 0x23 << 8,
|
||||||
|
/* For compatibility with misspellings */
|
||||||
|
RK_FORMAT_YCbCr_422_10b_SP = RK_FORMAT_YCbCr_422_SP_10B,
|
||||||
|
RK_FORMAT_YCrCb_422_10b_SP = RK_FORMAT_YCrCb_422_SP_10B,
|
||||||
|
|
||||||
|
RK_FORMAT_BGR_565 = 0x24 << 8,
|
||||||
|
RK_FORMAT_BGRA_5551 = 0x25 << 8,
|
||||||
|
RK_FORMAT_BGRA_4444 = 0x26 << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_ARGB_8888 = 0x28 << 8,
|
||||||
|
RK_FORMAT_XRGB_8888 = 0x29 << 8,
|
||||||
|
RK_FORMAT_ARGB_5551 = 0x2a << 8,
|
||||||
|
RK_FORMAT_ARGB_4444 = 0x2b << 8,
|
||||||
|
RK_FORMAT_ABGR_8888 = 0x2c << 8,
|
||||||
|
RK_FORMAT_XBGR_8888 = 0x2d << 8,
|
||||||
|
RK_FORMAT_ABGR_5551 = 0x2e << 8,
|
||||||
|
RK_FORMAT_ABGR_4444 = 0x2f << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_RGBA2BPP = 0x30 << 8,
|
||||||
|
|
||||||
|
RK_FORMAT_UNKNOWN = 0x100 << 8,
|
||||||
|
} RgaSURF_FORMAT;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
yuv2rgb_mode0 = 0x0, /* BT.601 MPEG */
|
||||||
|
yuv2rgb_mode1 = 0x1, /* BT.601 JPEG */
|
||||||
|
yuv2rgb_mode2 = 0x2, /* BT.709 */
|
||||||
|
|
||||||
|
rgb2yuv_601_full = 0x1 << 8,
|
||||||
|
rgb2yuv_709_full = 0x2 << 8,
|
||||||
|
yuv2yuv_601_limit_2_709_limit = 0x3 << 8,
|
||||||
|
yuv2yuv_601_limit_2_709_full = 0x4 << 8,
|
||||||
|
yuv2yuv_709_limit_2_601_limit = 0x5 << 8,
|
||||||
|
yuv2yuv_709_limit_2_601_full = 0x6 << 8, //not support
|
||||||
|
yuv2yuv_601_full_2_709_limit = 0x7 << 8,
|
||||||
|
yuv2yuv_601_full_2_709_full = 0x8 << 8, //not support
|
||||||
|
yuv2yuv_709_full_2_601_limit = 0x9 << 8, //not support
|
||||||
|
yuv2yuv_709_full_2_601_full = 0xa << 8, //not support
|
||||||
|
full_csc_mask = 0xf00,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
RGA3_SCHEDULER_CORE0 = 1 << 0,
|
||||||
|
RGA3_SCHEDULER_CORE1 = 1 << 1,
|
||||||
|
RGA2_SCHEDULER_CORE0 = 1 << 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* RGA3 rd_mode */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
raster_mode = 0x1 << 0,
|
||||||
|
fbc_mode = 0x1 << 1,
|
||||||
|
tile_mode = 0x1 << 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_RK29_IPP_DRIVER_H_*/
|
BIN
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/lib/Linux/aarch64/librga.a
vendored
Normal file
BIN
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/lib/Linux/aarch64/librga.a
vendored
Normal file
Binary file not shown.
BIN
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/lib/Linux/aarch64/librga.so
vendored
Normal file
BIN
Code/RK3588/stereo_yolo/obj_dec/obj_dec/src/3rdparty/rga/RK3588/lib/Linux/aarch64/librga.so
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,80 @@
|
||||||
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
|
project(rknn_yolov5_demo)
|
||||||
|
|
||||||
|
find_package(catkin REQUIRED COMPONENTS
|
||||||
|
roscpp
|
||||||
|
std_msgs
|
||||||
|
message_generation
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
find_package(OpenCV REQUIRED)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
add_message_files(
|
||||||
|
FILES
|
||||||
|
dis_info.msg
|
||||||
|
dis_info_array.msg
|
||||||
|
)
|
||||||
|
generate_messages(
|
||||||
|
DEPENDENCIES
|
||||||
|
std_msgs
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
catkin_package(
|
||||||
|
|
||||||
|
CATKIN_DEPENDS roscpp std_msgs message_runtime
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
include
|
||||||
|
${catkin_INCLUDE_DIRS}
|
||||||
|
${OpenCV_INCLUDE_DIRS}
|
||||||
|
/home/firefly/obj_dec/src/runtime/RK3588/Linux/librknn_api/include
|
||||||
|
/home/firefly/obj_dec/src/3rdparty/rga/RK3588/include
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(
|
||||||
|
head
|
||||||
|
include/rknn_yolov5_demo/detection.h
|
||||||
|
include/rknn_yolov5_demo/postprocess.h
|
||||||
|
include/rknn_yolov5_demo/preprocess.h
|
||||||
|
include/rknn_yolov5_demo/ranging.h
|
||||||
|
include/rknn_yolov5_demo/Timer.h
|
||||||
|
# include/rknn_yolov5_demo/pub_info.h
|
||||||
|
src/detection.cc
|
||||||
|
src/postprocess.cc
|
||||||
|
src/preprocess.cc
|
||||||
|
src/ranging.cc
|
||||||
|
# src/pub_info.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
add_dependencies(head ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
|
target_link_libraries(head
|
||||||
|
${catkin_LIBRARIES}
|
||||||
|
|
||||||
|
)
|
||||||
|
add_executable(main src/main.cc)
|
||||||
|
add_executable(sub_dis src/sub_dis.cc)
|
||||||
|
add_dependencies(main ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
|
add_dependencies(sub_dis ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
|
|
||||||
|
target_link_libraries(sub_dis
|
||||||
|
${catkin_LIBRARIES}
|
||||||
|
)
|
||||||
|
target_link_libraries(main
|
||||||
|
head
|
||||||
|
${catkin_LIBRARIES}
|
||||||
|
${OpenCV_LIBS}
|
||||||
|
Threads::Threads
|
||||||
|
/home/firefly/obj_dec/src/librknnrt.so
|
||||||
|
/home/firefly/obj_dec/src/librga.so
|
||||||
|
/home/firefly/obj_dec/src/libopencv_highgui.so
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
* @file Timer.h
|
||||||
|
* @author hcy
|
||||||
|
* @brief 用于计时
|
||||||
|
* @version 1
|
||||||
|
* @date 2023-04-10
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
class Timer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Timer()
|
||||||
|
{
|
||||||
|
start = std::chrono::high_resolution_clock::now();
|
||||||
|
};
|
||||||
|
~Timer()
|
||||||
|
{
|
||||||
|
end = std::chrono::high_resolution_clock::now();
|
||||||
|
duration = end - start;
|
||||||
|
double ms = duration.count() * 1000.f;
|
||||||
|
std::cout << "Timer took " << ms << "ms" << std::endl;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> start;
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> end;
|
||||||
|
std::chrono::duration<double> duration;
|
||||||
|
};
|
|
@ -0,0 +1,48 @@
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define _BASETSD_H
|
||||||
|
|
||||||
|
#include "rknn_api.h"
|
||||||
|
#include "rknn_yolov5_demo/preprocess.h"
|
||||||
|
#include "rknn_yolov5_demo/postprocess.h"
|
||||||
|
#include "rknn_yolov5_demo/Timer.h"
|
||||||
|
|
||||||
|
#define PERF_WITH_POST 1
|
||||||
|
|
||||||
|
class Detection
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
rknn_context ctx;
|
||||||
|
size_t actual_size = 0;
|
||||||
|
int img_width = 0;
|
||||||
|
int img_height = 0;
|
||||||
|
int img_channel = 0;
|
||||||
|
const float nms_threshold = NMS_THRESH; // 默认的NMS阈值
|
||||||
|
const float box_conf_threshold = BOX_THRESH; // 默认的置信度阈值
|
||||||
|
char* model_name = "/home/firefly/obj_dec/src/rknn_yolov5_demo/model/RK3588/yolov5s-640-640.rknn";
|
||||||
|
|
||||||
|
cv::Mat orig_img;
|
||||||
|
rknn_input_output_num io_num;
|
||||||
|
|
||||||
|
int channel = 3;
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
|
||||||
|
rknn_input inputs[1];
|
||||||
|
|
||||||
|
std::vector<float> out_scales;
|
||||||
|
std::vector<int32_t> out_zps;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Detection();
|
||||||
|
static unsigned char *load_data(FILE *fp, size_t ofst, size_t sz);
|
||||||
|
static unsigned char *load_model(const char *filename, int *model_size);
|
||||||
|
detect_result_group_t outputParse(cv::Mat netInputImg);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef _RKNN_YOLOV5_DEMO_POSTPROCESS_H_
|
||||||
|
#define _RKNN_YOLOV5_DEMO_POSTPROCESS_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#define OBJ_NAME_MAX_SIZE 16
|
||||||
|
#define OBJ_NUMB_MAX_SIZE 64
|
||||||
|
#define OBJ_CLASS_NUM 80
|
||||||
|
#define NMS_THRESH 0.45
|
||||||
|
#define BOX_THRESH 0.25
|
||||||
|
#define PROP_BOX_SIZE (5 + OBJ_CLASS_NUM)
|
||||||
|
|
||||||
|
typedef struct _BOX_RECT
|
||||||
|
{
|
||||||
|
int left;
|
||||||
|
int right;
|
||||||
|
int top;
|
||||||
|
int bottom;
|
||||||
|
} BOX_RECT;
|
||||||
|
|
||||||
|
typedef struct __detect_result_t
|
||||||
|
{
|
||||||
|
char name[OBJ_NAME_MAX_SIZE];
|
||||||
|
BOX_RECT box;
|
||||||
|
float prop;
|
||||||
|
} detect_result_t;
|
||||||
|
|
||||||
|
typedef struct _detect_result_group_t
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
int count;
|
||||||
|
detect_result_t results[OBJ_NUMB_MAX_SIZE];
|
||||||
|
} detect_result_group_t;
|
||||||
|
|
||||||
|
int post_process(int8_t *input0, int8_t *input1, int8_t *input2, int model_in_h, int model_in_w,
|
||||||
|
float conf_threshold, float nms_threshold, BOX_RECT pads, float scale_w, float scale_h,
|
||||||
|
std::vector<int32_t> &qnt_zps, std::vector<float> &qnt_scales,
|
||||||
|
detect_result_group_t *group);
|
||||||
|
|
||||||
|
void deinitPostProcess();
|
||||||
|
#endif //_RKNN_YOLOV5_DEMO_POSTPROCESS_H_
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _RKNN_YOLOV5_DEMO_PREPROCESS_H_
|
||||||
|
#define _RKNN_YOLOV5_DEMO_PREPROCESS_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "im2d.h"
|
||||||
|
#include "rga.h"
|
||||||
|
#include "opencv2/core/core.hpp"
|
||||||
|
#include "opencv2/imgcodecs.hpp"
|
||||||
|
#include "opencv2/imgproc.hpp"
|
||||||
|
#include "rknn_yolov5_demo/postprocess.h"
|
||||||
|
|
||||||
|
void letterbox(const cv::Mat &image, cv::Mat &padded_image, BOX_RECT &pads, const float scale, const cv::Size &target_size, const cv::Scalar &pad_color = cv::Scalar(128, 128, 128));
|
||||||
|
|
||||||
|
int resize_rga(rga_buffer_t &src, rga_buffer_t &dst, const cv::Mat &image, cv::Mat &resized_image, const cv::Size &target_size);
|
||||||
|
|
||||||
|
#endif //_RKNN_YOLOV5_DEMO_PREPROCESS_H_
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef PUB_INFO_H
|
||||||
|
#define PUB_INFO_H
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include <thread>
|
||||||
|
#include "rknn_yolov5_demo/dis_info.h"
|
||||||
|
#include "rknn_yolov5_demo/dis_info_array.h"
|
||||||
|
#include "rknn_yolov5_demo/ranging.h"
|
||||||
|
|
||||||
|
class Pub_info{
|
||||||
|
public:
|
||||||
|
Pub_info(){
|
||||||
|
dis_pub_ = nh_.advertise<rknn_yolov5_demo::dis_info_array>("ceju_info",10);
|
||||||
|
thread_1 = std::thread(&Pub_info::pub_dis,this);
|
||||||
|
// thread_2 = std::thread(&Pub_info::)
|
||||||
|
|
||||||
|
};
|
||||||
|
~Pub_info(){
|
||||||
|
thread_1.join();
|
||||||
|
}
|
||||||
|
void pub_dis();
|
||||||
|
public:
|
||||||
|
ros::NodeHandle nh_;
|
||||||
|
ros::Publisher dis_pub_;
|
||||||
|
rknn_yolov5_demo::dis_info_array dis_array_;
|
||||||
|
rknn_yolov5_demo::dis_info data;
|
||||||
|
std::thread thread_1;
|
||||||
|
// std::thread thread_2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
|
@ -0,0 +1,80 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <opencv2/calib3d.hpp>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <vector>
|
||||||
|
#include "rknn_yolov5_demo/detection.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace cv;
|
||||||
|
|
||||||
|
class Ranging
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// rknn_handle hdx;
|
||||||
|
cv::VideoCapture vcapture;
|
||||||
|
Detection yolov5s;
|
||||||
|
|
||||||
|
/* new stereo
|
||||||
|
Mat cam_matrix_left = (Mat_<double>(3, 3) <<
|
||||||
|
4.809895643547006e+02, 0, 0,
|
||||||
|
0,4.807599168204821e+02, 0,
|
||||||
|
3.362108165786334e+02, 2.298502481932070e+02, 1);
|
||||||
|
Mat cam_matrix_right = (Mat_<double>(3, 3) <<
|
||||||
|
4.903260126250775e+02, 0, 0,
|
||||||
|
0,4.900310486342847e+02, 0,
|
||||||
|
3.230124997386542e+02, 2.346297967642670e+02, 1);
|
||||||
|
Mat distortion_l = (Mat_<double>(1, 5) <<0.113688825569154,-0.106166584327678, 0,
|
||||||
|
0, 0);
|
||||||
|
|
||||||
|
Mat distortion_r = (Mat_<double>(1, 5) <<0.121425307936153,-0.141892782717707, 0,
|
||||||
|
0, 0);
|
||||||
|
Mat rotate = (Mat_<double>(3, 3) <<
|
||||||
|
0.999996295879846, 8.723884080433472e-04, 0.002578209660240,
|
||||||
|
-8.682590894537506e-04,0.999998339366207, -0.001602308016931,
|
||||||
|
-0.002579603213718,0.001600063527818,0.999995392711370);
|
||||||
|
Mat trans = (Mat_<double>(3, 1) <<
|
||||||
|
-60.348359844102470,-0.030699794141365, 0.495248628081046);
|
||||||
|
*/
|
||||||
|
Mat cam_matrix_left = (Mat_<double>(3, 3) <<
|
||||||
|
4.869084743604942e+02, 0, 0,
|
||||||
|
0,4.859921620798602e+02, 0,
|
||||||
|
2.813183643903652e+02, 2.267657091677993e+02, 1);
|
||||||
|
Mat cam_matrix_right = (Mat_<double>(3, 3) <<
|
||||||
|
4.859133331805883e+02, 0, 0,
|
||||||
|
0,4.850356748771951e+02, 0,
|
||||||
|
2.970046483040089e+02, 2.324763397214774e+02, 1);
|
||||||
|
Mat distortion_l = (Mat_<double>(1, 5) <<0.121235284781974,-0.161097849662596, 0,
|
||||||
|
0, 0);
|
||||||
|
|
||||||
|
Mat distortion_r = (Mat_<double>(1, 5) <<0.105479235005840,-0.120347246815955, 0,
|
||||||
|
0, 0);
|
||||||
|
Mat rotate = (Mat_<double>(3, 3) <<
|
||||||
|
0.999921984818601, 3.753847738839353e-04, -0.012485325894835,
|
||||||
|
-4.085449515452996e-04, 0.999996396040715, -0.002653487630467,
|
||||||
|
0.012484284819374, 0.002658381435011,0.999918534502034);
|
||||||
|
Mat trans = (Mat_<double>(3, 1) <<
|
||||||
|
-60.319997608188590, -0.019664800882533, -0.638993708428792);
|
||||||
|
|
||||||
|
cv::Mat mapX1, mapX2, mapY1, mapY2, q, Z;
|
||||||
|
|
||||||
|
int imgw, imgh;
|
||||||
|
detect_result_group_t detect_result_group;
|
||||||
|
cv::Mat info;
|
||||||
|
cv::Mat empty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
Ranging(){};
|
||||||
|
Ranging(int index, int imgw, int imgh);
|
||||||
|
void rectifyImage(cv::Mat &oriImgL, cv::Mat &oriImgR);
|
||||||
|
void getInfo(cv::Mat &imgl, cv::Mat &imgr, cv::Mat &detBoxes, cv::Mat &info);
|
||||||
|
std::vector<float> pic2cam(int u, int v);
|
||||||
|
std::vector<int> muban(cv::Mat &left_image, cv::Mat &right_image, const int *coordinates);
|
||||||
|
std::vector<cv::Mat> get_range();
|
||||||
|
void horizon_estimate(cv::Mat& img, cv::Mat& bboxs,int k);
|
||||||
|
};
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 177 KiB |
|
@ -0,0 +1,80 @@
|
||||||
|
person
|
||||||
|
bicycle
|
||||||
|
car
|
||||||
|
motorcycle
|
||||||
|
airplane
|
||||||
|
bus
|
||||||
|
train
|
||||||
|
truck
|
||||||
|
boat
|
||||||
|
traffic light
|
||||||
|
fire hydrant
|
||||||
|
stop sign
|
||||||
|
parking meter
|
||||||
|
bench
|
||||||
|
bird
|
||||||
|
cat
|
||||||
|
dog
|
||||||
|
horse
|
||||||
|
sheep
|
||||||
|
cow
|
||||||
|
elephant
|
||||||
|
bear
|
||||||
|
zebra
|
||||||
|
giraffe
|
||||||
|
backpack
|
||||||
|
umbrella
|
||||||
|
handbag
|
||||||
|
tie
|
||||||
|
suitcase
|
||||||
|
frisbee
|
||||||
|
skis
|
||||||
|
snowboard
|
||||||
|
sports ball
|
||||||
|
kite
|
||||||
|
baseball bat
|
||||||
|
baseball glove
|
||||||
|
skateboard
|
||||||
|
surfboard
|
||||||
|
tennis racket
|
||||||
|
bottle
|
||||||
|
wine glass
|
||||||
|
cup
|
||||||
|
fork
|
||||||
|
knife
|
||||||
|
spoon
|
||||||
|
bowl
|
||||||
|
banana
|
||||||
|
apple
|
||||||
|
sandwich
|
||||||
|
orange
|
||||||
|
broccoli
|
||||||
|
carrot
|
||||||
|
hot dog
|
||||||
|
pizza
|
||||||
|
donut
|
||||||
|
cake
|
||||||
|
chair
|
||||||
|
couch
|
||||||
|
potted plant
|
||||||
|
bed
|
||||||
|
dining table
|
||||||
|
toilet
|
||||||
|
tv
|
||||||
|
laptop
|
||||||
|
mouse
|
||||||
|
remote
|
||||||
|
keyboard
|
||||||
|
cell phone
|
||||||
|
microwave
|
||||||
|
oven
|
||||||
|
toaster
|
||||||
|
sink
|
||||||
|
refrigerator
|
||||||
|
book
|
||||||
|
clock
|
||||||
|
vase
|
||||||
|
scissors
|
||||||
|
teddy bear
|
||||||
|
hair drier
|
||||||
|
toothbrush
|
|
@ -0,0 +1,4 @@
|
||||||
|
float32 distance
|
||||||
|
float32 width
|
||||||
|
float32 height
|
||||||
|
float32 angle
|
|
@ -0,0 +1 @@
|
||||||
|
rknn_yolov5_demo/dis_info[] dis
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<package format="2">
|
||||||
|
<name>rknn_yolov5_demo</name>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
<description>The rknn_yolov5_demo package</description>
|
||||||
|
|
||||||
|
<!-- One maintainer tag required, multiple allowed, one person per tag -->
|
||||||
|
<!-- Example: -->
|
||||||
|
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
|
||||||
|
<maintainer email="firefly@todo.todo">firefly</maintainer>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- One license tag required, multiple allowed, one license per tag -->
|
||||||
|
<!-- Commonly used license strings: -->
|
||||||
|
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
|
||||||
|
<license>TODO</license>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Url tags are optional, but multiple are allowed, one per tag -->
|
||||||
|
<!-- Optional attribute type can be: website, bugtracker, or repository -->
|
||||||
|
<!-- Example: -->
|
||||||
|
<!-- <url type="website">http://wiki.ros.org/rknn_yolov5_demo</url> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Author tags are optional, multiple are allowed, one per tag -->
|
||||||
|
<!-- Authors do not have to be maintainers, but could be -->
|
||||||
|
<!-- Example: -->
|
||||||
|
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- The *depend tags are used to specify dependencies -->
|
||||||
|
<!-- Dependencies can be catkin packages or system dependencies -->
|
||||||
|
<!-- Examples: -->
|
||||||
|
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
|
||||||
|
<!-- <depend>roscpp</depend> -->
|
||||||
|
<!-- Note that this is equivalent to the following: -->
|
||||||
|
<!-- <build_depend>roscpp</build_depend> -->
|
||||||
|
<!-- <exec_depend>roscpp</exec_depend> -->
|
||||||
|
<!-- Use build_depend for packages you need at compile time: -->
|
||||||
|
<!-- <build_depend>message_generation</build_depend> -->
|
||||||
|
<!-- Use build_export_depend for packages you need in order to build against this package: -->
|
||||||
|
<!-- <build_export_depend>message_generation</build_export_depend> -->
|
||||||
|
<!-- Use buildtool_depend for build tool packages: -->
|
||||||
|
<!-- <buildtool_depend>catkin</buildtool_depend> -->
|
||||||
|
<!-- Use exec_depend for packages you need at runtime: -->
|
||||||
|
<!-- <exec_depend>message_runtime</exec_depend> -->
|
||||||
|
<!-- Use test_depend for packages you need only for testing: -->
|
||||||
|
<!-- <test_depend>gtest</test_depend> -->
|
||||||
|
<!-- Use doc_depend for packages you need only for building documentation: -->
|
||||||
|
<!-- <doc_depend>doxygen</doc_depend> -->
|
||||||
|
<buildtool_depend>catkin</buildtool_depend>
|
||||||
|
<build_depend>ros_py</build_depend>
|
||||||
|
<build_depend>roscpp</build_depend>
|
||||||
|
<build_depend>std_msgs</build_depend>
|
||||||
|
<build_export_depend>ros_py</build_export_depend>
|
||||||
|
<build_export_depend>roscpp</build_export_depend>
|
||||||
|
<build_export_depend>std_msgs</build_export_depend>
|
||||||
|
<exec_depend>ros_py</exec_depend>
|
||||||
|
<exec_depend>roscpp</exec_depend>
|
||||||
|
<exec_depend>std_msgs</exec_depend>
|
||||||
|
<build_depend>message_generation</build_depend>
|
||||||
|
<exec_depend>message_runtime</exec_depend>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- The export tag contains other, unspecified, tags -->
|
||||||
|
<export>
|
||||||
|
<!-- Other tools can request additional information be placed here -->
|
||||||
|
|
||||||
|
</export>
|
||||||
|
</package>
|
|
@ -0,0 +1,201 @@
|
||||||
|
#include "rknn_yolov5_demo/detection.h"
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char * Detection::load_data(FILE *fp, size_t ofst, size_t sz)
|
||||||
|
{
|
||||||
|
unsigned char *data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
data = NULL;
|
||||||
|
|
||||||
|
if (NULL == fp)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = fseek(fp, ofst, SEEK_SET);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
printf("blob seek failure.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (unsigned char *)malloc(sz);
|
||||||
|
if (data == NULL)
|
||||||
|
{
|
||||||
|
printf("buffer malloc failure.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ret = fread(data, 1, sz, fp);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char * Detection::load_model(const char *filename, int *model_size)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
unsigned char *data;
|
||||||
|
|
||||||
|
fp = fopen(filename, "rb");
|
||||||
|
if (NULL == fp)
|
||||||
|
{
|
||||||
|
printf("Open file %s failed.\n", filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek(fp, 0, SEEK_END);
|
||||||
|
int size = ftell(fp);
|
||||||
|
|
||||||
|
data = load_data(fp, 0, size);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
*model_size = size;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Detection::Detection()
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Create the neural network */
|
||||||
|
printf("Loading mode...\n");
|
||||||
|
int model_data_size = 0;
|
||||||
|
unsigned char *model_data = load_model(model_name, &model_data_size);
|
||||||
|
ret = rknn_init(&ctx, model_data, model_data_size, 0, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
printf("rknn_init error ret=%d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
rknn_sdk_version version;
|
||||||
|
ret = rknn_query(ctx, RKNN_QUERY_SDK_VERSION, &version, sizeof(rknn_sdk_version));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
printf("rknn_init error ret=%d\n", ret);
|
||||||
|
}
|
||||||
|
printf("sdk version: %s driver version: %s\n", version.api_version, version.drv_version);
|
||||||
|
|
||||||
|
ret = rknn_query(ctx, RKNN_QUERY_IN_OUT_NUM, &io_num, sizeof(io_num));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
printf("rknn_init error ret=%d\n", ret);
|
||||||
|
}
|
||||||
|
printf("model input num: %d, output num: %d\n", io_num.n_input, io_num.n_output);
|
||||||
|
|
||||||
|
rknn_tensor_attr input_attrs[io_num.n_input];
|
||||||
|
memset(input_attrs, 0, sizeof(input_attrs));
|
||||||
|
for (int i = 0; i < io_num.n_input; i++)
|
||||||
|
{
|
||||||
|
input_attrs[i].index = i;
|
||||||
|
ret = rknn_query(ctx, RKNN_QUERY_INPUT_ATTR, &(input_attrs[i]), sizeof(rknn_tensor_attr));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
printf("rknn_init error ret=%d\n", ret);
|
||||||
|
}
|
||||||
|
// dump_tensor_attr(&(input_attrs[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
rknn_tensor_attr output_attrs[io_num.n_output];
|
||||||
|
memset(output_attrs, 0, sizeof(output_attrs));
|
||||||
|
for (int i = 0; i < io_num.n_output; i++)
|
||||||
|
{
|
||||||
|
output_attrs[i].index = i;
|
||||||
|
ret = rknn_query(ctx, RKNN_QUERY_OUTPUT_ATTR, &(output_attrs[i]), sizeof(rknn_tensor_attr));
|
||||||
|
// dump_tensor_attr(&(output_attrs[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < io_num.n_output; ++i)
|
||||||
|
{
|
||||||
|
out_scales.push_back(output_attrs[i].scale);
|
||||||
|
out_zps.push_back(output_attrs[i].zp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input_attrs[0].fmt == RKNN_TENSOR_NCHW)
|
||||||
|
{
|
||||||
|
printf("model is NCHW input fmt\n");
|
||||||
|
channel = input_attrs[0].dims[1];
|
||||||
|
height = input_attrs[0].dims[2];
|
||||||
|
width = input_attrs[0].dims[3];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("model is NHWC input fmt\n");
|
||||||
|
height = input_attrs[0].dims[1];
|
||||||
|
width = input_attrs[0].dims[2];
|
||||||
|
channel = input_attrs[0].dims[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("model input height=%d, width=%d, channel=%d\n", height, width, channel);
|
||||||
|
|
||||||
|
|
||||||
|
memset(inputs, 0, sizeof(inputs));
|
||||||
|
inputs[0].index = 0;
|
||||||
|
inputs[0].type = RKNN_TENSOR_UINT8;
|
||||||
|
inputs[0].size = width * height * channel;
|
||||||
|
inputs[0].fmt = RKNN_TENSOR_NHWC;
|
||||||
|
inputs[0].pass_through = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_result_group_t Detection::outputParse(cv::Mat netInputImg)
|
||||||
|
{
|
||||||
|
|
||||||
|
orig_img = netInputImg.clone();
|
||||||
|
|
||||||
|
if (!orig_img.data)
|
||||||
|
{
|
||||||
|
printf("no image\n");
|
||||||
|
}
|
||||||
|
cv::Mat img;
|
||||||
|
cv::cvtColor(orig_img, img, cv::COLOR_BGR2RGB);
|
||||||
|
img_width = img.cols;
|
||||||
|
img_height = img.rows;
|
||||||
|
// printf("img width = %d, img height = %d\n", img_width, img_height);
|
||||||
|
|
||||||
|
// 指定目标大小和预处理方式,默认使用LetterBox的预处理
|
||||||
|
BOX_RECT pads;
|
||||||
|
memset(&pads, 0, sizeof(BOX_RECT));
|
||||||
|
cv::Size target_size(width, height);
|
||||||
|
cv::Mat resized_img(target_size.height, target_size.width, CV_8UC3);
|
||||||
|
// 计算缩放比例
|
||||||
|
float scale_w = (float)target_size.width / img.cols;
|
||||||
|
float scale_h = (float)target_size.height / img.rows;
|
||||||
|
|
||||||
|
if (img_width != width || img_height != height)
|
||||||
|
{
|
||||||
|
// printf("resize image with letterbox\n");
|
||||||
|
float min_scale = std::min(scale_w, scale_h);
|
||||||
|
scale_w = min_scale;
|
||||||
|
scale_h = min_scale;
|
||||||
|
letterbox(img, resized_img, pads, min_scale, target_size);
|
||||||
|
// 保存预处理图片
|
||||||
|
// cv::imwrite("letterbox_input.jpg", resized_img);
|
||||||
|
inputs[0].buf = resized_img.data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inputs[0].buf = img.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
rknn_inputs_set(ctx, io_num.n_input, inputs);
|
||||||
|
|
||||||
|
rknn_output outputs[io_num.n_output];
|
||||||
|
memset(outputs, 0, sizeof(outputs));
|
||||||
|
for (int i = 0; i < io_num.n_output; i++)
|
||||||
|
{
|
||||||
|
outputs[i].want_float = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行推理
|
||||||
|
ret = rknn_run(ctx, NULL);
|
||||||
|
ret = rknn_outputs_get(ctx, io_num.n_output, outputs, NULL);
|
||||||
|
|
||||||
|
// 后处理
|
||||||
|
detect_result_group_t detect_result_group;
|
||||||
|
|
||||||
|
post_process((int8_t *)outputs[0].buf, (int8_t *)outputs[1].buf, (int8_t *)outputs[2].buf, height, width,
|
||||||
|
box_conf_threshold, nms_threshold, pads, scale_w, scale_h, out_zps, out_scales, &detect_result_group);
|
||||||
|
|
||||||
|
|
||||||
|
return detect_result_group;
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include "rknn_yolov5_demo/ranging.h"
|
||||||
|
#include <string>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <mutex>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include "opencv2/imgcodecs/imgcodecs.hpp"
|
||||||
|
#include <ctime>
|
||||||
|
#include <queue>
|
||||||
|
#include "rknn_yolov5_demo/dis_info.h"
|
||||||
|
#include "rknn_yolov5_demo/dis_info_array.h"
|
||||||
|
|
||||||
|
#define ANGLE_TO_RADIAN(angle) ((angle)*3141.59 / 180000)
|
||||||
|
|
||||||
|
Ranging r(11, 640, 480);
|
||||||
|
std::queue<std::vector<cv::Mat>> frameInfo;
|
||||||
|
std::mutex g_mutex;
|
||||||
|
|
||||||
|
void *ranging(void *args) // ranging线程
|
||||||
|
{
|
||||||
|
ros::Publisher dis_pub_;
|
||||||
|
ros::NodeHandle nh;
|
||||||
|
dis_pub_ = nh.advertise<rknn_yolov5_demo::dis_info_array>("ceju_info",10);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// std::cout<<" ************ enter ranging *********** "<<std::endl;
|
||||||
|
std::vector<cv::Mat> result = r.get_range();
|
||||||
|
cv ::Mat info = result[2];
|
||||||
|
rknn_yolov5_demo::dis_info_array dis_array;
|
||||||
|
if(!info.empty())
|
||||||
|
{
|
||||||
|
for(int i=0;i<info.rows;i++)
|
||||||
|
{
|
||||||
|
// std::cout<<"1"<<std::endl;
|
||||||
|
if(info.at<float>(i,0)>0&&info.at<float>(i,0)<200)
|
||||||
|
{
|
||||||
|
rknn_yolov5_demo::dis_info data;
|
||||||
|
data.distance = info.at<float>(i,0);
|
||||||
|
data.width = info.at<float>(i,1);
|
||||||
|
data.height = info.at<float>(i,2);
|
||||||
|
data.angle = info.at<float>(i,3);
|
||||||
|
dis_array.dis.push_back(data);
|
||||||
|
std::cout<<data.distance<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dis_pub_.publish(dis_array);
|
||||||
|
// if (!dis_array.dis.empty())
|
||||||
|
// {
|
||||||
|
// for (const auto& data : dis_array.dis)
|
||||||
|
// {
|
||||||
|
// ROS_INFO("distance: %.2f, width: %.2f, height: %.2f, angle: %.2f",
|
||||||
|
// data.distance, data.width, data.height, data.angle);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// else{
|
||||||
|
// std::cerr << "Info matrix is empty!" << std::endl;
|
||||||
|
// }
|
||||||
|
g_mutex.lock();
|
||||||
|
for (uchar i = 0; i < frameInfo.size(); i++) // 只保存当前最新的图片帧信息
|
||||||
|
frameInfo.pop();
|
||||||
|
frameInfo.push(result);
|
||||||
|
g_mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
ros::init(argc, argv, "stereo");
|
||||||
|
ros::NodeHandle nh;
|
||||||
|
pthread_t tids[1]; // 执行ranging线程
|
||||||
|
int ret = pthread_create(&tids[0], NULL, ranging, NULL);
|
||||||
|
pthread_join(tids[0],NULL);
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,373 @@
|
||||||
|
// Copyright (c) 2021 by Rockchip Electronics Co., Ltd. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "rknn_yolov5_demo/postprocess.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <set>
|
||||||
|
#include <vector>
|
||||||
|
#define LABEL_NALE_TXT_PATH "/home/firefly/obj_dec/src/rknn_yolov5_demo/model/coco_80_labels_list.txt"
|
||||||
|
|
||||||
|
static char *labels[OBJ_CLASS_NUM];
|
||||||
|
|
||||||
|
const int anchor0[6] = {10, 13, 16, 30, 33, 23};
|
||||||
|
const int anchor1[6] = {30, 61, 62, 45, 59, 119};
|
||||||
|
const int anchor2[6] = {116, 90, 156, 198, 373, 326};
|
||||||
|
|
||||||
|
inline static int clamp(float val, int min, int max) { return val > min ? (val < max ? val : max) : min; }
|
||||||
|
|
||||||
|
char *readLine(FILE *fp, char *buffer, int *len)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
int i = 0;
|
||||||
|
size_t buff_len = 0;
|
||||||
|
|
||||||
|
buffer = (char *)malloc(buff_len + 1);
|
||||||
|
if (!buffer)
|
||||||
|
return NULL; // Out of memory
|
||||||
|
|
||||||
|
while ((ch = fgetc(fp)) != '\n' && ch != EOF)
|
||||||
|
{
|
||||||
|
buff_len++;
|
||||||
|
void *tmp = realloc(buffer, buff_len + 1);
|
||||||
|
if (tmp == NULL)
|
||||||
|
{
|
||||||
|
free(buffer);
|
||||||
|
return NULL; // Out of memory
|
||||||
|
}
|
||||||
|
buffer = (char *)tmp;
|
||||||
|
|
||||||
|
buffer[i] = (char)ch;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
buffer[i] = '\0';
|
||||||
|
|
||||||
|
*len = buff_len;
|
||||||
|
|
||||||
|
// Detect end
|
||||||
|
if (ch == EOF && (i == 0 || ferror(fp)))
|
||||||
|
{
|
||||||
|
free(buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
int readLines(const char *fileName, char *lines[], int max_line)
|
||||||
|
{
|
||||||
|
FILE *file = fopen(fileName, "r");
|
||||||
|
char *s;
|
||||||
|
int i = 0;
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
printf("Open %s fail!\n", fileName);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((s = readLine(file, s, &n)) != NULL)
|
||||||
|
{
|
||||||
|
lines[i++] = s;
|
||||||
|
if (i >= max_line)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fclose(file);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int loadLabelName(const char *locationFilename, char *label[])
|
||||||
|
{
|
||||||
|
printf("loadLabelName %s\n", locationFilename);
|
||||||
|
readLines(locationFilename, label, OBJ_CLASS_NUM);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float CalculateOverlap(float xmin0, float ymin0, float xmax0, float ymax0, float xmin1, float ymin1, float xmax1,
|
||||||
|
float ymax1)
|
||||||
|
{
|
||||||
|
float w = fmax(0.f, fmin(xmax0, xmax1) - fmax(xmin0, xmin1) + 1.0);
|
||||||
|
float h = fmax(0.f, fmin(ymax0, ymax1) - fmax(ymin0, ymin1) + 1.0);
|
||||||
|
float i = w * h;
|
||||||
|
float u = (xmax0 - xmin0 + 1.0) * (ymax0 - ymin0 + 1.0) + (xmax1 - xmin1 + 1.0) * (ymax1 - ymin1 + 1.0) - i;
|
||||||
|
return u <= 0.f ? 0.f : (i / u);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int nms(int validCount, std::vector<float> &outputLocations, std::vector<int> classIds, std::vector<int> &order,
|
||||||
|
int filterId, float threshold)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < validCount; ++i)
|
||||||
|
{
|
||||||
|
if (order[i] == -1 || classIds[i] != filterId)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int n = order[i];
|
||||||
|
for (int j = i + 1; j < validCount; ++j)
|
||||||
|
{
|
||||||
|
int m = order[j];
|
||||||
|
if (m == -1 || classIds[i] != filterId)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
float xmin0 = outputLocations[n * 4 + 0];
|
||||||
|
float ymin0 = outputLocations[n * 4 + 1];
|
||||||
|
float xmax0 = outputLocations[n * 4 + 0] + outputLocations[n * 4 + 2];
|
||||||
|
float ymax0 = outputLocations[n * 4 + 1] + outputLocations[n * 4 + 3];
|
||||||
|
|
||||||
|
float xmin1 = outputLocations[m * 4 + 0];
|
||||||
|
float ymin1 = outputLocations[m * 4 + 1];
|
||||||
|
float xmax1 = outputLocations[m * 4 + 0] + outputLocations[m * 4 + 2];
|
||||||
|
float ymax1 = outputLocations[m * 4 + 1] + outputLocations[m * 4 + 3];
|
||||||
|
|
||||||
|
float iou = CalculateOverlap(xmin0, ymin0, xmax0, ymax0, xmin1, ymin1, xmax1, ymax1);
|
||||||
|
|
||||||
|
if (iou > threshold)
|
||||||
|
{
|
||||||
|
order[j] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int quick_sort_indice_inverse(std::vector<float> &input, int left, int right, std::vector<int> &indices)
|
||||||
|
{
|
||||||
|
float key;
|
||||||
|
int key_index;
|
||||||
|
int low = left;
|
||||||
|
int high = right;
|
||||||
|
if (left < right)
|
||||||
|
{
|
||||||
|
key_index = indices[left];
|
||||||
|
key = input[left];
|
||||||
|
while (low < high)
|
||||||
|
{
|
||||||
|
while (low < high && input[high] <= key)
|
||||||
|
{
|
||||||
|
high--;
|
||||||
|
}
|
||||||
|
input[low] = input[high];
|
||||||
|
indices[low] = indices[high];
|
||||||
|
while (low < high && input[low] >= key)
|
||||||
|
{
|
||||||
|
low++;
|
||||||
|
}
|
||||||
|
input[high] = input[low];
|
||||||
|
indices[high] = indices[low];
|
||||||
|
}
|
||||||
|
input[low] = key;
|
||||||
|
indices[low] = key_index;
|
||||||
|
quick_sort_indice_inverse(input, left, low - 1, indices);
|
||||||
|
quick_sort_indice_inverse(input, low + 1, right, indices);
|
||||||
|
}
|
||||||
|
return low;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float sigmoid(float x) { return 1.0 / (1.0 + expf(-x)); }
|
||||||
|
|
||||||
|
static float unsigmoid(float y) { return -1.0 * logf((1.0 / y) - 1.0); }
|
||||||
|
|
||||||
|
inline static int32_t __clip(float val, float min, float max)
|
||||||
|
{
|
||||||
|
float f = val <= min ? min : (val >= max ? max : val);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int8_t qnt_f32_to_affine(float f32, int32_t zp, float scale)
|
||||||
|
{
|
||||||
|
float dst_val = (f32 / scale) + zp;
|
||||||
|
int8_t res = (int8_t)__clip(dst_val, -128, 127);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float deqnt_affine_to_f32(int8_t qnt, int32_t zp, float scale) { return ((float)qnt - (float)zp) * scale; }
|
||||||
|
|
||||||
|
static int process(int8_t *input, int *anchor, int grid_h, int grid_w, int height, int width, int stride,
|
||||||
|
std::vector<float> &boxes, std::vector<float> &objProbs, std::vector<int> &classId, float threshold,
|
||||||
|
int32_t zp, float scale)
|
||||||
|
{
|
||||||
|
int validCount = 0;
|
||||||
|
int grid_len = grid_h * grid_w;
|
||||||
|
int8_t thres_i8 = qnt_f32_to_affine(threshold, zp, scale);
|
||||||
|
for (int a = 0; a < 3; a++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < grid_h; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < grid_w; j++)
|
||||||
|
{
|
||||||
|
int8_t box_confidence = input[(PROP_BOX_SIZE * a + 4) * grid_len + i * grid_w + j];
|
||||||
|
if (box_confidence >= thres_i8)
|
||||||
|
{
|
||||||
|
int offset = (PROP_BOX_SIZE * a) * grid_len + i * grid_w + j;
|
||||||
|
int8_t *in_ptr = input + offset;
|
||||||
|
float box_x = (deqnt_affine_to_f32(*in_ptr, zp, scale)) * 2.0 - 0.5;
|
||||||
|
float box_y = (deqnt_affine_to_f32(in_ptr[grid_len], zp, scale)) * 2.0 - 0.5;
|
||||||
|
float box_w = (deqnt_affine_to_f32(in_ptr[2 * grid_len], zp, scale)) * 2.0;
|
||||||
|
float box_h = (deqnt_affine_to_f32(in_ptr[3 * grid_len], zp, scale)) * 2.0;
|
||||||
|
box_x = (box_x + j) * (float)stride;
|
||||||
|
box_y = (box_y + i) * (float)stride;
|
||||||
|
box_w = box_w * box_w * (float)anchor[a * 2];
|
||||||
|
box_h = box_h * box_h * (float)anchor[a * 2 + 1];
|
||||||
|
box_x -= (box_w / 2.0);
|
||||||
|
box_y -= (box_h / 2.0);
|
||||||
|
|
||||||
|
int8_t maxClassProbs = in_ptr[5 * grid_len];
|
||||||
|
int maxClassId = 0;
|
||||||
|
for (int k = 1; k < OBJ_CLASS_NUM; ++k)
|
||||||
|
{
|
||||||
|
int8_t prob = in_ptr[(5 + k) * grid_len];
|
||||||
|
if (prob > maxClassProbs)
|
||||||
|
{
|
||||||
|
maxClassId = k;
|
||||||
|
maxClassProbs = prob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (maxClassProbs > thres_i8)
|
||||||
|
{
|
||||||
|
objProbs.push_back((deqnt_affine_to_f32(maxClassProbs, zp, scale)) * (deqnt_affine_to_f32(box_confidence, zp, scale)));
|
||||||
|
classId.push_back(maxClassId);
|
||||||
|
validCount++;
|
||||||
|
boxes.push_back(box_x);
|
||||||
|
boxes.push_back(box_y);
|
||||||
|
boxes.push_back(box_w);
|
||||||
|
boxes.push_back(box_h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
int post_process(int8_t *input0, int8_t *input1, int8_t *input2, int model_in_h, int model_in_w, float conf_threshold,
|
||||||
|
float nms_threshold, BOX_RECT pads, float scale_w, float scale_h, std::vector<int32_t> &qnt_zps,
|
||||||
|
std::vector<float> &qnt_scales, detect_result_group_t *group)
|
||||||
|
{
|
||||||
|
static int init = -1;
|
||||||
|
if (init == -1)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
ret = loadLabelName(LABEL_NALE_TXT_PATH, labels);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
init = 0;
|
||||||
|
}
|
||||||
|
memset(group, 0, sizeof(detect_result_group_t));
|
||||||
|
|
||||||
|
std::vector<float> filterBoxes;
|
||||||
|
std::vector<float> objProbs;
|
||||||
|
std::vector<int> classId;
|
||||||
|
|
||||||
|
// stride 8
|
||||||
|
int stride0 = 8;
|
||||||
|
int grid_h0 = model_in_h / stride0;
|
||||||
|
int grid_w0 = model_in_w / stride0;
|
||||||
|
int validCount0 = 0;
|
||||||
|
validCount0 = process(input0, (int *)anchor0, grid_h0, grid_w0, model_in_h, model_in_w, stride0, filterBoxes, objProbs,
|
||||||
|
classId, conf_threshold, qnt_zps[0], qnt_scales[0]);
|
||||||
|
|
||||||
|
// stride 16
|
||||||
|
int stride1 = 16;
|
||||||
|
int grid_h1 = model_in_h / stride1;
|
||||||
|
int grid_w1 = model_in_w / stride1;
|
||||||
|
int validCount1 = 0;
|
||||||
|
validCount1 = process(input1, (int *)anchor1, grid_h1, grid_w1, model_in_h, model_in_w, stride1, filterBoxes, objProbs,
|
||||||
|
classId, conf_threshold, qnt_zps[1], qnt_scales[1]);
|
||||||
|
|
||||||
|
// stride 32
|
||||||
|
int stride2 = 32;
|
||||||
|
int grid_h2 = model_in_h / stride2;
|
||||||
|
int grid_w2 = model_in_w / stride2;
|
||||||
|
int validCount2 = 0;
|
||||||
|
validCount2 = process(input2, (int *)anchor2, grid_h2, grid_w2, model_in_h, model_in_w, stride2, filterBoxes, objProbs,
|
||||||
|
classId, conf_threshold, qnt_zps[2], qnt_scales[2]);
|
||||||
|
|
||||||
|
int validCount = validCount0 + validCount1 + validCount2;
|
||||||
|
// no object detect
|
||||||
|
if (validCount <= 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> indexArray;
|
||||||
|
for (int i = 0; i < validCount; ++i)
|
||||||
|
{
|
||||||
|
indexArray.push_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
quick_sort_indice_inverse(objProbs, 0, validCount - 1, indexArray);
|
||||||
|
|
||||||
|
std::set<int> class_set(std::begin(classId), std::end(classId));
|
||||||
|
|
||||||
|
for (auto c : class_set)
|
||||||
|
{
|
||||||
|
nms(validCount, filterBoxes, classId, indexArray, c, nms_threshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
int last_count = 0;
|
||||||
|
group->count = 0;
|
||||||
|
/* box valid detect target */
|
||||||
|
for (int i = 0; i < validCount; ++i)
|
||||||
|
{
|
||||||
|
if (indexArray[i] == -1 || last_count >= OBJ_NUMB_MAX_SIZE)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int n = indexArray[i];
|
||||||
|
|
||||||
|
float x1 = filterBoxes[n * 4 + 0] - pads.left;
|
||||||
|
float y1 = filterBoxes[n * 4 + 1] - pads.top;
|
||||||
|
float x2 = x1 + filterBoxes[n * 4 + 2];
|
||||||
|
float y2 = y1 + filterBoxes[n * 4 + 3];
|
||||||
|
int id = classId[n];
|
||||||
|
float obj_conf = objProbs[i];
|
||||||
|
|
||||||
|
group->results[last_count].box.left = (int)(clamp(x1, 0, model_in_w) / scale_w);
|
||||||
|
group->results[last_count].box.top = (int)(clamp(y1, 0, model_in_h) / scale_h);
|
||||||
|
group->results[last_count].box.right = (int)(clamp(x2, 0, model_in_w) / scale_w);
|
||||||
|
group->results[last_count].box.bottom = (int)(clamp(y2, 0, model_in_h) / scale_h);
|
||||||
|
group->results[last_count].prop = obj_conf;
|
||||||
|
char *label = labels[id];
|
||||||
|
strncpy(group->results[last_count].name, label, OBJ_NAME_MAX_SIZE);
|
||||||
|
|
||||||
|
// printf("result %2d: (%4d, %4d, %4d, %4d), %s\n", i, group->results[last_count].box.left,
|
||||||
|
// group->results[last_count].box.top,
|
||||||
|
// group->results[last_count].box.right, group->results[last_count].box.bottom, label);
|
||||||
|
last_count++;
|
||||||
|
}
|
||||||
|
group->count = last_count;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void deinitPostProcess()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < OBJ_CLASS_NUM; i++)
|
||||||
|
{
|
||||||
|
if (labels[i] != nullptr)
|
||||||
|
{
|
||||||
|
free(labels[i]);
|
||||||
|
labels[i] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright (c) 2023 by Rockchip Electronics Co., Ltd. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "rknn_yolov5_demo/preprocess.h"
|
||||||
|
|
||||||
|
void letterbox(const cv::Mat &image, cv::Mat &padded_image, BOX_RECT &pads, const float scale, const cv::Size &target_size, const cv::Scalar &pad_color)
|
||||||
|
{
|
||||||
|
// 调整图像大小
|
||||||
|
cv::Mat resized_image;
|
||||||
|
cv::resize(image, resized_image, cv::Size(), scale, scale);
|
||||||
|
|
||||||
|
// 计算填充大小
|
||||||
|
int pad_width = target_size.width - resized_image.cols;
|
||||||
|
int pad_height = target_size.height - resized_image.rows;
|
||||||
|
|
||||||
|
pads.left = pad_width / 2;
|
||||||
|
pads.right = pad_width - pads.left;
|
||||||
|
pads.top = pad_height / 2;
|
||||||
|
pads.bottom = pad_height - pads.top;
|
||||||
|
|
||||||
|
// 在图像周围添加填充
|
||||||
|
cv::copyMakeBorder(resized_image, padded_image, pads.top, pads.bottom, pads.left, pads.right, cv::BORDER_CONSTANT, pad_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
int resize_rga(rga_buffer_t &src, rga_buffer_t &dst, const cv::Mat &image, cv::Mat &resized_image, const cv::Size &target_size)
|
||||||
|
{
|
||||||
|
im_rect src_rect;
|
||||||
|
im_rect dst_rect;
|
||||||
|
memset(&src_rect, 0, sizeof(src_rect));
|
||||||
|
memset(&dst_rect, 0, sizeof(dst_rect));
|
||||||
|
size_t img_width = image.cols;
|
||||||
|
size_t img_height = image.rows;
|
||||||
|
if (image.type() != CV_8UC3)
|
||||||
|
{
|
||||||
|
printf("source image type is %d!\n", image.type());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
size_t target_width = target_size.width;
|
||||||
|
size_t target_height = target_size.height;
|
||||||
|
src = wrapbuffer_virtualaddr((void *)image.data, img_width, img_height, RK_FORMAT_RGB_888);
|
||||||
|
dst = wrapbuffer_virtualaddr((void *)resized_image.data, target_width, target_height, RK_FORMAT_RGB_888);
|
||||||
|
int ret = imcheck(src, dst, src_rect, dst_rect);
|
||||||
|
if (IM_STATUS_NOERROR != ret)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "rga check error! %s", imStrError((IM_STATUS)ret));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
IM_STATUS STATUS = imresize(src, dst);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "rknn_yolov5_demo/pub_info.h"
|
||||||
|
|
||||||
|
|
||||||
|
void Pub_info::pub_dis()
|
||||||
|
{
|
||||||
|
Ranging ranging;
|
||||||
|
ros::Rate loop_rate(10);
|
||||||
|
|
||||||
|
while(ros::ok()){
|
||||||
|
std::vector<cv::Mat> result = ranging.get_range();
|
||||||
|
cv::Mat info = result[2];
|
||||||
|
for(int i=0;i<info.rows;i++)
|
||||||
|
{
|
||||||
|
data.distance = info.at<float>(i,0);
|
||||||
|
data.width = info.at<float>(i,1);
|
||||||
|
data.height = info.at<float>(i,2);
|
||||||
|
data.angle = info.at<float>(i,3);
|
||||||
|
dis_array_.dis.push_back(data);
|
||||||
|
}
|
||||||
|
dis_pub_.publish(dis_array_);
|
||||||
|
loop_rate.sleep();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,392 @@
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <opencv2/highgui.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "rknn_yolov5_demo/ranging.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include "opencv2/core.hpp"
|
||||||
|
#include "opencv2/imgcodecs.hpp"
|
||||||
|
#include "opencv2/imgproc.hpp"
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <tuple>
|
||||||
|
#include <string>
|
||||||
|
#include <string.h>
|
||||||
|
#include <algorithm>
|
||||||
|
// #include <ros/ros.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace cv;
|
||||||
|
void Ranging::rectifyImage(Mat &oriImgL, Mat &oriImgR) //重映射函数
|
||||||
|
{
|
||||||
|
remap(oriImgL, oriImgL, mapX1, mapX2, cv::INTER_LINEAR);
|
||||||
|
remap(oriImgR, oriImgR, mapY1, mapY2, cv::INTER_LINEAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<float> Ranging::pic2cam(int u, int v) //像素坐标转相机坐标
|
||||||
|
{
|
||||||
|
//(u,v)->(x,y)"(loc[0],loc[1])"
|
||||||
|
std::vector<float> loc;
|
||||||
|
loc.push_back((u - cam_matrix_right.at<double>(0, 2)) * q.at<double>(2, 3) / cam_matrix_right.at<double>(0, 0));
|
||||||
|
loc.push_back((v - cam_matrix_right.at<double>(1, 2)) * q.at<double>(2, 3) / cam_matrix_right.at<double>(1, 1));
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> Ranging::muban(Mat &left_image, Mat &right_image, const int *coordinates) //模板匹配
|
||||||
|
{
|
||||||
|
int x1 = coordinates[0], y1 = coordinates[1], x2 = coordinates[2], y2 = coordinates[3];
|
||||||
|
Mat tpl = right_image.rowRange(max(y1 - 2, 0), min(y2 + 2, 479)).colRange(x1, x2); //获取目标框
|
||||||
|
Mat target = left_image.rowRange(max(y1 - 20, 0), min(y2 + 20, 479)).colRange(0, 639); //待匹配图像,极线约束,只需要同水平区域
|
||||||
|
int th = tpl.rows, tw = tpl.cols;
|
||||||
|
Mat result;
|
||||||
|
|
||||||
|
matchTemplate(target, tpl, result, TM_CCOEFF_NORMED); //匹配方法:归一化相关系数即零均值归一化互相关
|
||||||
|
double minVal, maxVal;
|
||||||
|
Point minLoc, maxLoc;
|
||||||
|
minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc); //得到匹配点坐标
|
||||||
|
Point tl = maxLoc, br;
|
||||||
|
|
||||||
|
br.x = min(maxLoc.x + tw, 639); //转为像素坐标系
|
||||||
|
br.y = min(maxLoc.y + th, 479); //转为像素坐标系
|
||||||
|
////展示匹配结果
|
||||||
|
// br.x = min(maxLoc.x + tw, 319);
|
||||||
|
// br.y = min(maxLoc.y + th, 239);
|
||||||
|
//rectangle(target, tl, br, (0, 255, 0), 3);
|
||||||
|
//imshow("match-", target);
|
||||||
|
//waitKey(2);
|
||||||
|
|
||||||
|
std::vector<int> maxloc;
|
||||||
|
maxloc.push_back(maxLoc.x);
|
||||||
|
maxloc.push_back(maxLoc.y);
|
||||||
|
return maxloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ranging::horizon_estimate(Mat& img, Mat& bboxs,int k)
|
||||||
|
{
|
||||||
|
//保证摄像头与地面平行
|
||||||
|
int x1 = bboxs.at<float>(k, 0);
|
||||||
|
int x2 = bboxs.at<float>(k, 2);
|
||||||
|
int y1 = bboxs.at<float>(k, 1);
|
||||||
|
int y2 = bboxs.at<float>(k, 3);
|
||||||
|
float Conf = bboxs.at<float>(k, 4);
|
||||||
|
int cls = bboxs.at<float>(k, 5);
|
||||||
|
float Y_B, Y_H;
|
||||||
|
cv::Mat edge, grayImage;
|
||||||
|
std::vector<cv::Point> idx;
|
||||||
|
cv::Mat tpl = img.rowRange(y1, min(y2+5,479)).colRange(x1, x2); // 取感兴趣范围
|
||||||
|
//Mat target = left_image.rowRange(max(y1 - 20, 0), min(y2 + 20, 479)).colRange(0, 639);
|
||||||
|
cv::Mat Z = Mat::zeros(2, tpl.cols, CV_32FC1);
|
||||||
|
cvtColor(tpl, grayImage, COLOR_BGR2GRAY);
|
||||||
|
GaussianBlur(grayImage,grayImage,Size(5,5),0);
|
||||||
|
Canny(grayImage, edge, 120, 180, 3); //提取边缘,获取与地面接触点
|
||||||
|
//cv::imshow("1",edge);
|
||||||
|
//cv::waitKey(1);
|
||||||
|
float cluster[650];
|
||||||
|
for (int i = 0;i<650;i++)
|
||||||
|
{
|
||||||
|
cluster[i] = 0;
|
||||||
|
}
|
||||||
|
int y_b, y_h;
|
||||||
|
int j = 0;
|
||||||
|
for (int i = 0; i < x2-x1; i++)
|
||||||
|
{
|
||||||
|
//Mat temp = edge.rowRange(max(y1, 0), min(y2 + 4, 479)).colRange(x1, x2);
|
||||||
|
Mat temp = edge.col(i); //取第i列
|
||||||
|
// std::cout << "temp: " <<temp << std::endl;
|
||||||
|
cv::findNonZero(temp, idx);
|
||||||
|
std::vector<float> point_b = pic2cam(x1 + i, 240); //转为相机坐标系
|
||||||
|
std::vector<float> point_H = pic2cam(320, 240);
|
||||||
|
float alfa = atan((point_b[0] - point_H[0]) / q.at<double>(2, 3));
|
||||||
|
if (idx.size() < 1)
|
||||||
|
{
|
||||||
|
Z.at<float>(0, i) = 0;
|
||||||
|
Z.at<float>(1, i) = alfa;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int y_b = idx[idx.size() - 1].y + y1; //
|
||||||
|
y_b = int(y_b + y_b*0.03);
|
||||||
|
int y_h = 240;
|
||||||
|
point_b = pic2cam(x1 + i, y_b); //转为相机坐标系
|
||||||
|
point_H = pic2cam(320, y_h);
|
||||||
|
Y_B = point_b[1];
|
||||||
|
Y_H = point_H[1];
|
||||||
|
|
||||||
|
float H_c = 60; //摄像头离地高度,单位mm
|
||||||
|
float theta = 0; //摄像头与地面夹角,弧度
|
||||||
|
float d = (1/cos(theta)* cos(theta)) * q.at<double>(2, 3) * H_c / (Y_B - Y_H)- H_c*tan(theta);
|
||||||
|
alfa = atan((point_b[0] - point_H[0]) / q.at<double>(2, 3));
|
||||||
|
//cout << "d: " << d << endl;
|
||||||
|
if (d > 700)
|
||||||
|
{d = 0;}
|
||||||
|
Z.at<float>(0, i) = d/cos(alfa);
|
||||||
|
Z.at<float>(1, i) = alfa;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->Z = Z.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ranging::getInfo(Mat &imgL, Mat &imgR, Mat &detBoxes, Mat &info)
|
||||||
|
{
|
||||||
|
Mat imgGrayL, imgGrayR;
|
||||||
|
cvtColor(imgL, imgGrayL, COLOR_BGR2GRAY);
|
||||||
|
cvtColor(imgR, imgGrayR, COLOR_BGR2GRAY);
|
||||||
|
Mat imgR_weight = imgR.clone();
|
||||||
|
Mat infoRow;
|
||||||
|
for (uchar i = 0; i < detBoxes.rows; i++)
|
||||||
|
{
|
||||||
|
int x1 = detBoxes.at<float>(i, 0);
|
||||||
|
int y1 = detBoxes.at<float>(i, 1);
|
||||||
|
int x2 = detBoxes.at<float>(i, 2);
|
||||||
|
int y2 = detBoxes.at<float>(i, 3);
|
||||||
|
|
||||||
|
float Conf = detBoxes.at<float>(i, 4);
|
||||||
|
|
||||||
|
if (x1 > 600 || x2 < 50 || y1 < 5 || y2 > 475 || x1 < 2 || x2 > 590 || abs(x2 - x1) > 550) //当目标框偏左、偏右或者过大,略去该物体
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// rectangle(imgR, Point(int(x1), int(y1)),
|
||||||
|
// Point(int(x2), int(y2)), Scalar(0, 0, 255)); //绘制目标框
|
||||||
|
|
||||||
|
int coordinates[4] = {x1, y1, x2, y2};
|
||||||
|
std::vector<int> disp_pixel = muban(imgGrayL, imgGrayR, coordinates); //模板匹配
|
||||||
|
float disp_pixel_x = disp_pixel[0] - x1; //ˮ计算水平视差
|
||||||
|
float disp_pixel_y = disp_pixel[1] - y1; //
|
||||||
|
disp_pixel_x = (int)(disp_pixel_x + disp_pixel_x * 0.12); //0.12为模板匹配产生的误差,为经验值,通过拟合得到
|
||||||
|
|
||||||
|
//Mat disp_matrix = Mat(1, 1, CV_32F, Scalar(disp_pixel_x)), disp_pixel_xyz;
|
||||||
|
Mat disp_matrix = Mat(imgGrayL.rows, imgGrayL.cols, CV_32F, Scalar(disp_pixel_x)); //定义视差矩阵,所有值均为水平视差,方便转换为三维坐标,并具有水平距离信息
|
||||||
|
Mat threed_pixel_xyz, threedImage;
|
||||||
|
reprojectImageTo3D(disp_matrix, threedImage, q, false); //2d->3d
|
||||||
|
threed_pixel_xyz = threedImage.mul(threedImage); //每一像素点求平方,
|
||||||
|
std::vector<Mat> channels;
|
||||||
|
split(threed_pixel_xyz.clone(), channels);
|
||||||
|
threed_pixel_xyz = channels[0] + channels[1] + channels[2]; //计算欧式距离
|
||||||
|
threed_pixel_xyz.forEach<float>([](float &value, const int *position) { value = sqrt(value); }); // 获得距离d
|
||||||
|
|
||||||
|
int mid_pixel = int((x1 + x2) / 2);
|
||||||
|
std::vector<float> mid = pic2cam(imgGrayR.cols / 2, imgGrayR.rows); //计算角度,从像素坐标转为相机坐标
|
||||||
|
std::vector<float> loc_tar = pic2cam(mid_pixel, imgGrayR.rows);
|
||||||
|
float alfa = atan((loc_tar[0] - mid[0]) / q.at<double>(2, 3));
|
||||||
|
|
||||||
|
|
||||||
|
if (disp_pixel_x > 240) // 距离太近,视差过大
|
||||||
|
{
|
||||||
|
char cm[15];
|
||||||
|
//sprintf(cm, "cannot match !");
|
||||||
|
// sprintf(cm, "%d , %.2f", cls,Conf);
|
||||||
|
putText(imgR, cm, Point((x1), (y1)), FONT_HERSHEY_PLAIN, 2.2, Scalar(0, 0, 255), 2);
|
||||||
|
infoRow = (Mat_<float>(1, 4) << -1, -1, -1, -1);
|
||||||
|
infoRow.copyTo(info.row(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float median = threed_pixel_xyz.at<float>((int)(y1 + y2) / 2, (int)(x1 + x2) / 2);
|
||||||
|
|
||||||
|
std::vector<float> ltPoint = pic2cam(x1, y1);
|
||||||
|
std::vector<float> rbPoint = pic2cam(x2, y2);
|
||||||
|
float xx1 = ltPoint[0], yy1 = ltPoint[1], xx2 = rbPoint[0], yy2 = rbPoint[1]; //计算宽高
|
||||||
|
float f = q.at<double>(2, 3);
|
||||||
|
float f1 = sqrt(xx1 * xx1 + yy1 * yy1 + f * f); //推导得出
|
||||||
|
//float w1 = median * sqrt((xx1 - xx2) * (xx1 - xx2) / 4) / f1;
|
||||||
|
float h1 = median * sqrt((yy1 - yy2) * (yy1 - yy2) / 4) / f1;
|
||||||
|
float f2 = sqrt(xx2 * xx2 + yy2 * yy2 + f * f);
|
||||||
|
//float w2 = median * sqrt((xx2 - xx1) * (xx2 - xx1) / 4) / f2;
|
||||||
|
float h2 = median * sqrt((yy2 - yy1) * (yy2 - yy1) / 4) / f2;
|
||||||
|
float w1 = sqrt(pow((threedImage.at<cv::Vec3f>(y2, x1)[0] - threedImage.at<cv::Vec3f>(y2, x2)[0]), 2) +
|
||||||
|
pow((threedImage.at<cv::Vec3f>(y2, x1)[1] - threedImage.at<cv::Vec3f>(y2, x2)[1]), 2) +
|
||||||
|
pow((threedImage.at<cv::Vec3f>(y2, x1)[2] - threedImage.at<cv::Vec3f>(y2, x2)[2]), 2));
|
||||||
|
|
||||||
|
w1 = w1 / 10;
|
||||||
|
h1 = (h1 + h2) / 10;
|
||||||
|
median /= 10;
|
||||||
|
if (median > 120) //过远测距误差较大
|
||||||
|
{
|
||||||
|
//char tf[9];
|
||||||
|
//sprintf(tf, "Too far!");
|
||||||
|
char cm[15];
|
||||||
|
//sprintf(cm, "cannot match !");
|
||||||
|
// sprintf(cm, "%d , %.2f", cls,Conf);
|
||||||
|
putText(imgR, cm, Point((x1), (y1)), FONT_HERSHEY_PLAIN, 2.2, Scalar(0, 0, 255), 2);
|
||||||
|
infoRow = (Mat_<float>(1, 4) << -1, -1, -1, -1);
|
||||||
|
infoRow.copyTo(info.row(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// <20><>ͼ<EFBFBD><CDBC><EFBFBD>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
|
// char dc[50], wh[50];
|
||||||
|
// std::string cname = className[cls + 1];
|
||||||
|
// sprintf(dc, "dis:%.2fcm %d", median, cls);
|
||||||
|
// sprintf(wh, "W: %.2fcm H: %.2fcm alfa: %2f", w1, h1, alfa);
|
||||||
|
// putText(imgR, dc, Point(x1, y2), FONT_HERSHEY_PLAIN, 1.5, Scalar(0, 0, 255), 2);
|
||||||
|
// putText(imgR, wh, Point(x1, y1), FONT_HERSHEY_PLAIN, 1.5, Scalar(0, 0, 255), 1.5);
|
||||||
|
|
||||||
|
|
||||||
|
//返回数据
|
||||||
|
infoRow = (Mat_<float>(1, 4) << median, w1, h1, alfa);
|
||||||
|
infoRow.copyTo(info.row(i));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// cv::imshow("kk",imgR);
|
||||||
|
// cv::waitKey(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Ranging::Ranging(int index, int imgw, int imgh) : //初始化
|
||||||
|
mapX1(imgh, imgw, CV_64F), //初始化矩阵 ,用于计算无畸变和修正转换映射。
|
||||||
|
mapX2(imgh, imgw, CV_64F),
|
||||||
|
mapY1(imgh, imgw, CV_64F),
|
||||||
|
mapY2(imgh, imgw, CV_64F),
|
||||||
|
q(4, 4, CV_64F),
|
||||||
|
imgw(imgw),
|
||||||
|
imgh(imgh)
|
||||||
|
{
|
||||||
|
// Z = Mat::zeros(2, 1, CV_32FC1);
|
||||||
|
vcapture = cv::VideoCapture(index);
|
||||||
|
//vcapture.set(CAP_PROP_FOURCC, CAP_OPENCV_MJPEG);
|
||||||
|
vcapture.set(cv::CAP_PROP_FPS, 30);
|
||||||
|
vcapture.set(cv::CAP_PROP_FRAME_WIDTH, imgw * 2);
|
||||||
|
vcapture.set(cv::CAP_PROP_FRAME_HEIGHT, imgh);
|
||||||
|
vcapture.set(cv::CAP_PROP_BUFFERSIZE, 1);
|
||||||
|
|
||||||
|
|
||||||
|
auto imgSize = Size(imgw, imgh);
|
||||||
|
Mat r1(3, 3, CV_64F), r2(3, 3, CV_64F), p1(3, 4, CV_64F), p2(3, 4, CV_64F);
|
||||||
|
|
||||||
|
stereoRectify(cam_matrix_left.t(), distortion_l, cam_matrix_right.t(), distortion_r,
|
||||||
|
imgSize, rotate.t(), trans, r1, r2, p1, p2, q);//立体校正
|
||||||
|
|
||||||
|
initUndistortRectifyMap(cam_matrix_left.t(), distortion_l, r1, p1, imgSize, CV_32F, mapX1, mapX2);//计算无畸变和修正转换映射
|
||||||
|
initUndistortRectifyMap(cam_matrix_right.t(), distortion_r, r2, p2, imgSize, CV_32F, mapY1, mapY2);//计算无畸变和修正转换映射
|
||||||
|
|
||||||
|
// RKNN_Create(&hdx, modelPath); // 初始化检测模型
|
||||||
|
std::cout<< " ******************* CAMERA initialization ********************" << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<Mat> Ranging::get_range()
|
||||||
|
{
|
||||||
|
|
||||||
|
double rang_old, rang_now;
|
||||||
|
// rang_old = ros::Time::now().toSec(); //测试运行时间
|
||||||
|
Mat frame, lframe, rframe;
|
||||||
|
// vcapture.read(frame); //获取视频帧
|
||||||
|
vcapture >> frame;
|
||||||
|
|
||||||
|
// cv::imshow("frame",frame);
|
||||||
|
|
||||||
|
if (!frame.empty())
|
||||||
|
{
|
||||||
|
int64 t = getTickCount();
|
||||||
|
Mat lframe(frame.colRange(0, imgw).clone()); //拷贝左图
|
||||||
|
Mat rframe(frame.colRange(imgw, imgw * 2).clone()); //拷贝右图
|
||||||
|
|
||||||
|
rectifyImage(lframe, rframe); //
|
||||||
|
|
||||||
|
cv::Mat Rframe = rframe.clone();
|
||||||
|
|
||||||
|
detect_result_group = yolov5s.outputParse(Rframe);
|
||||||
|
|
||||||
|
if (detect_result_group.count<=0)
|
||||||
|
{
|
||||||
|
std::cout<<"detect nothing"<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// detction box transfor to our format
|
||||||
|
Mat detBoxes(detect_result_group.count, 5, CV_32F); //定义矩阵,存储目标检测内容,存储格式(x,y,x,y,conf,cls)
|
||||||
|
char text[256];
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < detect_result_group.count; i++) //存储目标检测内容 (x,y,x,y,conf,cls)
|
||||||
|
{
|
||||||
|
detect_result_t *det_result = &(detect_result_group.results[i]);
|
||||||
|
|
||||||
|
// if(strcmp(det_result->name, "person") == 0 || strcmp(det_result->name, "bottle") == 0|| strcmp(det_result->name, "cup") == 0)
|
||||||
|
if(strcmp(det_result->name, "vase") == 0|| strcmp(det_result->name, "suitcase") == 0)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
sprintf(text, "%s %.1f%%", det_result->name, det_result->prop * 100);
|
||||||
|
// printf("%s @ (%d %d %d %d) %f\n", det_result->name, det_result->box.left, det_result->box.top,
|
||||||
|
// det_result->box.right, det_result->box.bottom, det_result->prop);
|
||||||
|
|
||||||
|
int xmin = det_result->box.left;
|
||||||
|
int ymin = det_result->box.top;
|
||||||
|
int xmax = det_result->box.right;
|
||||||
|
int ymax = det_result->box.bottom;
|
||||||
|
|
||||||
|
rectangle(Rframe, cv::Point(xmin, ymin), cv::Point(xmax, ymax), cv::Scalar(256, 0, 0, 256), 3);
|
||||||
|
putText(Rframe, text, cv::Point(xmin, ymin + 12), cv::FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(255, 255, 255));
|
||||||
|
|
||||||
|
// (x,y) (x,y) conf
|
||||||
|
detBoxes.at<float>(count-1, 0) = xmin;
|
||||||
|
detBoxes.at<float>(count-1, 1) = ymin;
|
||||||
|
detBoxes.at<float>(count-1, 2) = xmax;
|
||||||
|
detBoxes.at<float>(count-1, 3) = ymax;
|
||||||
|
detBoxes.at<float>(count-1, 4) = det_result->prop;
|
||||||
|
// detBoxes.at<float>(i, 0) = xmin;
|
||||||
|
// detBoxes.at<float>(i, 1) = ymin;
|
||||||
|
// detBoxes.at<float>(i, 2) = xmax;
|
||||||
|
// detBoxes.at<float>(i, 3) = ymax;
|
||||||
|
// detBoxes.at<float>(i, 4) = det_result->prop;
|
||||||
|
}
|
||||||
|
// 实验测试,过滤过大的误检框*/
|
||||||
|
// float ratio = (xmax - xmin) * (ymax - ymin) / 308480.;
|
||||||
|
// if (ratio > 0.7)
|
||||||
|
// {
|
||||||
|
// detBoxes.at<float>(i, 5) = -1;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
Mat finalBoxes(detBoxes, Range(0, count), Range::all());
|
||||||
|
Mat info(count, 4, CV_32F); // 存储测距信息,存储格式:距离d,宽w,高h,角度α
|
||||||
|
// Mat info(detect_result_group.count, 4, CV_32F); // 存储测距信息,存储格式:距离d,宽w,高h,角度α
|
||||||
|
if (count)
|
||||||
|
// if (detect_result_group.count)
|
||||||
|
{
|
||||||
|
getInfo(lframe, rframe, finalBoxes, info);
|
||||||
|
// getInfo(lframe, rframe, detBoxes, info);
|
||||||
|
|
||||||
|
for(int i=0; i<info.rows;i++)
|
||||||
|
{
|
||||||
|
float median = info.at<float>(i, 0);
|
||||||
|
// float w1 = info.at<float>(i, 1);
|
||||||
|
// float h1 = info.at<float>(i, 2);
|
||||||
|
// float alfa = info.at<float>(i, 3);
|
||||||
|
|
||||||
|
int x1 = finalBoxes.at<float>(i,0);
|
||||||
|
int y1 = finalBoxes.at<float>(i,1);
|
||||||
|
int x2 = finalBoxes.at<float>(i,2);
|
||||||
|
int y2 = finalBoxes.at<float>(i,3);
|
||||||
|
|
||||||
|
char dc[50], wh[50];
|
||||||
|
sprintf(dc, "dis:%.2fcm ", median);
|
||||||
|
// sprintf(wh, "W: %.2fcm H: %.2fcm ", w1, h1);
|
||||||
|
putText(Rframe, dc, Point(x1, y2), cv::FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(255, 255, 255));
|
||||||
|
// putText(Rframe, wh, Point(x1, y1), cv::FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(255, 255, 255));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t = getTickCount() - t;
|
||||||
|
char fps[50];
|
||||||
|
sprintf(fps, "fps: %d", int(1 / (t / getTickFrequency())));
|
||||||
|
putText(Rframe, fps, Point(20, 20), FONT_HERSHEY_PLAIN, 1, Scalar(0, 0, 255), 1.5);
|
||||||
|
|
||||||
|
cv::imshow("k",Rframe);
|
||||||
|
cv::waitKey(1);
|
||||||
|
return std::vector<Mat>{rframe, detBoxes, info};
|
||||||
|
}
|
||||||
|
return std::vector<Mat>{empty};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include "ros/ros.h"
|
||||||
|
#include "rknn_yolov5_demo/dis_info.h"
|
||||||
|
#include "rknn_yolov5_demo/dis_info_array.h"
|
||||||
|
|
||||||
|
void doMsg(const rknn_yolov5_demo::dis_info_array::ConstPtr& ceju_msg){
|
||||||
|
|
||||||
|
for (const auto& obstacle_info : ceju_msg->dis)
|
||||||
|
{
|
||||||
|
|
||||||
|
float distance = obstacle_info.distance;
|
||||||
|
float width = obstacle_info.width;
|
||||||
|
float height = obstacle_info.height;
|
||||||
|
ROS_INFO("distance: %.2f ", distance);
|
||||||
|
|
||||||
|
// // 执行避障逻辑
|
||||||
|
// if (distance < obstacle_distance_threshold)
|
||||||
|
// {
|
||||||
|
// ROS_INFO("Obstacle detected at distance: %.2f meters. Avoiding obstacle.", distance);
|
||||||
|
|
||||||
|
// // 在这里执行避障动作,例如停止机器人
|
||||||
|
// geometry_msgs::Twist cmd_vel;
|
||||||
|
// cmd_vel.linear.x = 0.0;
|
||||||
|
// cmd_vel.angular.z = 0.0;
|
||||||
|
// cmd_vel_pub.publish(cmd_vel);
|
||||||
|
|
||||||
|
// // 这里可以添加更复杂的避障逻辑,例如避开障碍物或调整方向
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// ROS_INFO("No obstacle detected at distance: %.2f meters. Continuing.", distance);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
setlocale(LC_ALL,"");
|
||||||
|
ros::init(argc,argv,"sub_dis");
|
||||||
|
ros::NodeHandle nh;
|
||||||
|
ros::Subscriber sub = nh.subscribe<rknn_yolov5_demo::dis_info_array>("ceju_info",10,doMsg);
|
||||||
|
|
||||||
|
ros::spin();//循环读取接收的数据,并调用回调函数处理
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,720 @@
|
||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 - 2022 by Rockchip Corp. All rights reserved.
|
||||||
|
*
|
||||||
|
* The material in this file is confidential and contains trade secrets
|
||||||
|
* of Rockchip Corporation. This is proprietary information owned by
|
||||||
|
* Rockchip Corporation. No part of this work may be disclosed,
|
||||||
|
* reproduced, copied, transmitted, or used in any way for any purpose,
|
||||||
|
* without the express written permission of Rockchip Corporation.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _RKNN_API_H
|
||||||
|
#define _RKNN_API_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Definition of extended flag for rknn_init.
|
||||||
|
*/
|
||||||
|
/* set high priority context. */
|
||||||
|
#define RKNN_FLAG_PRIOR_HIGH 0x00000000
|
||||||
|
|
||||||
|
/* set medium priority context */
|
||||||
|
#define RKNN_FLAG_PRIOR_MEDIUM 0x00000001
|
||||||
|
|
||||||
|
/* set low priority context. */
|
||||||
|
#define RKNN_FLAG_PRIOR_LOW 0x00000002
|
||||||
|
|
||||||
|
/* asynchronous mode.
|
||||||
|
when enable, rknn_outputs_get will not block for too long because it directly retrieves the result of
|
||||||
|
the previous frame which can increase the frame rate on single-threaded mode, but at the cost of
|
||||||
|
rknn_outputs_get not retrieves the result of the current frame.
|
||||||
|
in multi-threaded mode you do not need to turn this mode on. */
|
||||||
|
#define RKNN_FLAG_ASYNC_MASK 0x00000004
|
||||||
|
|
||||||
|
/* collect performance mode.
|
||||||
|
when enable, you can get detailed performance reports via rknn_query(ctx, RKNN_QUERY_PERF_DETAIL, ...),
|
||||||
|
but it will reduce the frame rate. */
|
||||||
|
#define RKNN_FLAG_COLLECT_PERF_MASK 0x00000008
|
||||||
|
|
||||||
|
/* allocate all memory in outside, includes weight/internal/inputs/outputs */
|
||||||
|
#define RKNN_FLAG_MEM_ALLOC_OUTSIDE 0x00000010
|
||||||
|
|
||||||
|
/* weight sharing with the same network structure */
|
||||||
|
#define RKNN_FLAG_SHARE_WEIGHT_MEM 0x00000020
|
||||||
|
|
||||||
|
/* send fence fd from outside */
|
||||||
|
#define RKNN_FLAG_FENCE_IN_OUTSIDE 0x00000040
|
||||||
|
|
||||||
|
/* get fence fd from inside */
|
||||||
|
#define RKNN_FLAG_FENCE_OUT_OUTSIDE 0x00000080
|
||||||
|
|
||||||
|
/* dummy init flag: could only get total_weight_size and total_internal_size by rknn_query*/
|
||||||
|
#define RKNN_FLAG_COLLECT_MODEL_INFO_ONLY 0x00000100
|
||||||
|
|
||||||
|
/* set GPU as the preferred execution backend When the operator is not supported by the NPU */
|
||||||
|
#define RKNN_FLAG_EXECUTE_FALLBACK_PRIOR_DEVICE_GPU 0x00000400
|
||||||
|
|
||||||
|
/* allocate internal memory in outside */
|
||||||
|
#define RKNN_FLAG_INTERNAL_ALLOC_OUTSIDE 0x00000200
|
||||||
|
|
||||||
|
/*
|
||||||
|
Error code returned by the RKNN API.
|
||||||
|
*/
|
||||||
|
#define RKNN_SUCC 0 /* execute succeed. */
|
||||||
|
#define RKNN_ERR_FAIL -1 /* execute failed. */
|
||||||
|
#define RKNN_ERR_TIMEOUT -2 /* execute timeout. */
|
||||||
|
#define RKNN_ERR_DEVICE_UNAVAILABLE -3 /* device is unavailable. */
|
||||||
|
#define RKNN_ERR_MALLOC_FAIL -4 /* memory malloc fail. */
|
||||||
|
#define RKNN_ERR_PARAM_INVALID -5 /* parameter is invalid. */
|
||||||
|
#define RKNN_ERR_MODEL_INVALID -6 /* model is invalid. */
|
||||||
|
#define RKNN_ERR_CTX_INVALID -7 /* context is invalid. */
|
||||||
|
#define RKNN_ERR_INPUT_INVALID -8 /* input is invalid. */
|
||||||
|
#define RKNN_ERR_OUTPUT_INVALID -9 /* output is invalid. */
|
||||||
|
#define RKNN_ERR_DEVICE_UNMATCH -10 /* the device is unmatch, please update rknn sdk
|
||||||
|
and npu driver/firmware. */
|
||||||
|
#define RKNN_ERR_INCOMPATILE_PRE_COMPILE_MODEL -11 /* This RKNN model use pre_compile mode, but not compatible with current driver. */
|
||||||
|
#define RKNN_ERR_INCOMPATILE_OPTIMIZATION_LEVEL_VERSION -12 /* This RKNN model set optimization level, but not compatible with current driver. */
|
||||||
|
#define RKNN_ERR_TARGET_PLATFORM_UNMATCH -13 /* This RKNN model set target platform, but not compatible with current platform. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
Definition for tensor
|
||||||
|
*/
|
||||||
|
#define RKNN_MAX_DIMS 16 /* maximum dimension of tensor. */
|
||||||
|
#define RKNN_MAX_NUM_CHANNEL 15 /* maximum channel number of input tensor. */
|
||||||
|
#define RKNN_MAX_NAME_LEN 256 /* maximum name lenth of tensor. */
|
||||||
|
#define RKNN_MAX_DYNAMIC_SHAPE_NUM 512 /* maximum number of dynamic shape for each input. */
|
||||||
|
|
||||||
|
#ifdef __arm__
|
||||||
|
typedef uint32_t rknn_context;
|
||||||
|
#else
|
||||||
|
typedef uint64_t rknn_context;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
The query command for rknn_query
|
||||||
|
*/
|
||||||
|
typedef enum _rknn_query_cmd {
|
||||||
|
RKNN_QUERY_IN_OUT_NUM = 0, /* query the number of input & output tensor. */
|
||||||
|
RKNN_QUERY_INPUT_ATTR = 1, /* query the attribute of input tensor. */
|
||||||
|
RKNN_QUERY_OUTPUT_ATTR = 2, /* query the attribute of output tensor. */
|
||||||
|
RKNN_QUERY_PERF_DETAIL = 3, /* query the detail performance, need set
|
||||||
|
RKNN_FLAG_COLLECT_PERF_MASK when call rknn_init,
|
||||||
|
this query needs to be valid after rknn_outputs_get. */
|
||||||
|
RKNN_QUERY_PERF_RUN = 4, /* query the time of run,
|
||||||
|
this query needs to be valid after rknn_outputs_get. */
|
||||||
|
RKNN_QUERY_SDK_VERSION = 5, /* query the sdk & driver version */
|
||||||
|
|
||||||
|
RKNN_QUERY_MEM_SIZE = 6, /* query the weight & internal memory size */
|
||||||
|
RKNN_QUERY_CUSTOM_STRING = 7, /* query the custom string */
|
||||||
|
|
||||||
|
RKNN_QUERY_NATIVE_INPUT_ATTR = 8, /* query the attribute of native input tensor. */
|
||||||
|
RKNN_QUERY_NATIVE_OUTPUT_ATTR = 9, /* query the attribute of native output tensor. */
|
||||||
|
|
||||||
|
RKNN_QUERY_NATIVE_NC1HWC2_INPUT_ATTR = 8, /* query the attribute of native input tensor. */
|
||||||
|
RKNN_QUERY_NATIVE_NC1HWC2_OUTPUT_ATTR = 9, /* query the attribute of native output tensor. */
|
||||||
|
|
||||||
|
RKNN_QUERY_NATIVE_NHWC_INPUT_ATTR = 10, /* query the attribute of native input tensor. */
|
||||||
|
RKNN_QUERY_NATIVE_NHWC_OUTPUT_ATTR = 11, /* query the attribute of native output tensor. */
|
||||||
|
|
||||||
|
RKNN_QUERY_DEVICE_MEM_INFO = 12, /* query the attribute of rknn memory information. */
|
||||||
|
|
||||||
|
RKNN_QUERY_INPUT_DYNAMIC_RANGE = 13, /* query the dynamic shape range of rknn input tensor. */
|
||||||
|
RKNN_QUERY_CURRENT_INPUT_ATTR = 14, /* query the current shape of rknn input tensor, only valid for dynamic rknn model*/
|
||||||
|
RKNN_QUERY_CURRENT_OUTPUT_ATTR = 15, /* query the current shape of rknn output tensor, only valid for dynamic rknn model*/
|
||||||
|
|
||||||
|
RKNN_QUERY_CURRENT_NATIVE_INPUT_ATTR = 16, /* query the current native shape of rknn input tensor, only valid for dynamic rknn model*/
|
||||||
|
RKNN_QUERY_CURRENT_NATIVE_OUTPUT_ATTR = 17, /* query the current native shape of rknn output tensor, only valid for dynamic rknn model*/
|
||||||
|
|
||||||
|
|
||||||
|
RKNN_QUERY_CMD_MAX
|
||||||
|
} rknn_query_cmd;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the tensor data type.
|
||||||
|
*/
|
||||||
|
typedef enum _rknn_tensor_type {
|
||||||
|
RKNN_TENSOR_FLOAT32 = 0, /* data type is float32. */
|
||||||
|
RKNN_TENSOR_FLOAT16, /* data type is float16. */
|
||||||
|
RKNN_TENSOR_INT8, /* data type is int8. */
|
||||||
|
RKNN_TENSOR_UINT8, /* data type is uint8. */
|
||||||
|
RKNN_TENSOR_INT16, /* data type is int16. */
|
||||||
|
RKNN_TENSOR_UINT16, /* data type is uint16. */
|
||||||
|
RKNN_TENSOR_INT32, /* data type is int32. */
|
||||||
|
RKNN_TENSOR_UINT32, /* data type is uint32. */
|
||||||
|
RKNN_TENSOR_INT64, /* data type is int64. */
|
||||||
|
RKNN_TENSOR_BOOL,
|
||||||
|
|
||||||
|
RKNN_TENSOR_TYPE_MAX
|
||||||
|
} rknn_tensor_type;
|
||||||
|
|
||||||
|
inline static const char* get_type_string(rknn_tensor_type type)
|
||||||
|
{
|
||||||
|
switch(type) {
|
||||||
|
case RKNN_TENSOR_FLOAT32: return "FP32";
|
||||||
|
case RKNN_TENSOR_FLOAT16: return "FP16";
|
||||||
|
case RKNN_TENSOR_INT8: return "INT8";
|
||||||
|
case RKNN_TENSOR_UINT8: return "UINT8";
|
||||||
|
case RKNN_TENSOR_INT16: return "INT16";
|
||||||
|
case RKNN_TENSOR_UINT16: return "UINT16";
|
||||||
|
case RKNN_TENSOR_INT32: return "INT32";
|
||||||
|
case RKNN_TENSOR_UINT32: return "UINT32";
|
||||||
|
case RKNN_TENSOR_INT64: return "INT64";
|
||||||
|
case RKNN_TENSOR_BOOL: return "BOOL";
|
||||||
|
default: return "UNKNOW";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
the quantitative type.
|
||||||
|
*/
|
||||||
|
typedef enum _rknn_tensor_qnt_type {
|
||||||
|
RKNN_TENSOR_QNT_NONE = 0, /* none. */
|
||||||
|
RKNN_TENSOR_QNT_DFP, /* dynamic fixed point. */
|
||||||
|
RKNN_TENSOR_QNT_AFFINE_ASYMMETRIC, /* asymmetric affine. */
|
||||||
|
|
||||||
|
RKNN_TENSOR_QNT_MAX
|
||||||
|
} rknn_tensor_qnt_type;
|
||||||
|
|
||||||
|
inline static const char* get_qnt_type_string(rknn_tensor_qnt_type type)
|
||||||
|
{
|
||||||
|
switch(type) {
|
||||||
|
case RKNN_TENSOR_QNT_NONE: return "NONE";
|
||||||
|
case RKNN_TENSOR_QNT_DFP: return "DFP";
|
||||||
|
case RKNN_TENSOR_QNT_AFFINE_ASYMMETRIC: return "AFFINE";
|
||||||
|
default: return "UNKNOW";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
the tensor data format.
|
||||||
|
*/
|
||||||
|
typedef enum _rknn_tensor_format {
|
||||||
|
RKNN_TENSOR_NCHW = 0, /* data format is NCHW. */
|
||||||
|
RKNN_TENSOR_NHWC, /* data format is NHWC. */
|
||||||
|
RKNN_TENSOR_NC1HWC2, /* data format is NC1HWC2. */
|
||||||
|
RKNN_TENSOR_UNDEFINED,
|
||||||
|
|
||||||
|
RKNN_TENSOR_FORMAT_MAX
|
||||||
|
} rknn_tensor_format;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the mode of running on target NPU core.
|
||||||
|
*/
|
||||||
|
typedef enum _rknn_core_mask {
|
||||||
|
RKNN_NPU_CORE_AUTO = 0, /* default, run on NPU core randomly. */
|
||||||
|
RKNN_NPU_CORE_0 = 1, /* run on NPU core 0. */
|
||||||
|
RKNN_NPU_CORE_1 = 2, /* run on NPU core 1. */
|
||||||
|
RKNN_NPU_CORE_2 = 4, /* run on NPU core 2. */
|
||||||
|
RKNN_NPU_CORE_0_1 = RKNN_NPU_CORE_0 | RKNN_NPU_CORE_1, /* run on NPU core 0 and core 1. */
|
||||||
|
RKNN_NPU_CORE_0_1_2 = RKNN_NPU_CORE_0_1 | RKNN_NPU_CORE_2, /* run on NPU core 0 and core 1 and core 2. */
|
||||||
|
|
||||||
|
RKNN_NPU_CORE_UNDEFINED,
|
||||||
|
} rknn_core_mask;
|
||||||
|
|
||||||
|
inline static const char* get_format_string(rknn_tensor_format fmt)
|
||||||
|
{
|
||||||
|
switch(fmt) {
|
||||||
|
case RKNN_TENSOR_NCHW: return "NCHW";
|
||||||
|
case RKNN_TENSOR_NHWC: return "NHWC";
|
||||||
|
case RKNN_TENSOR_NC1HWC2: return "NC1HWC2";
|
||||||
|
case RKNN_TENSOR_UNDEFINED: return "UNDEFINED";
|
||||||
|
default: return "UNKNOW";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
the information for RKNN_QUERY_IN_OUT_NUM.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_input_output_num {
|
||||||
|
uint32_t n_input; /* the number of input. */
|
||||||
|
uint32_t n_output; /* the number of output. */
|
||||||
|
} rknn_input_output_num;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the information for RKNN_QUERY_INPUT_ATTR / RKNN_QUERY_OUTPUT_ATTR.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_tensor_attr {
|
||||||
|
uint32_t index; /* input parameter, the index of input/output tensor,
|
||||||
|
need set before call rknn_query. */
|
||||||
|
|
||||||
|
uint32_t n_dims; /* the number of dimensions. */
|
||||||
|
uint32_t dims[RKNN_MAX_DIMS]; /* the dimensions array. */
|
||||||
|
char name[RKNN_MAX_NAME_LEN]; /* the name of tensor. */
|
||||||
|
|
||||||
|
uint32_t n_elems; /* the number of elements. */
|
||||||
|
uint32_t size; /* the bytes size of tensor. */
|
||||||
|
|
||||||
|
rknn_tensor_format fmt; /* the data format of tensor. */
|
||||||
|
rknn_tensor_type type; /* the data type of tensor. */
|
||||||
|
rknn_tensor_qnt_type qnt_type; /* the quantitative type of tensor. */
|
||||||
|
int8_t fl; /* fractional length for RKNN_TENSOR_QNT_DFP. */
|
||||||
|
int32_t zp; /* zero point for RKNN_TENSOR_QNT_AFFINE_ASYMMETRIC. */
|
||||||
|
float scale; /* scale for RKNN_TENSOR_QNT_AFFINE_ASYMMETRIC. */
|
||||||
|
|
||||||
|
uint32_t w_stride; /* the stride of tensor along the width dimention of input,
|
||||||
|
Note: it is read-only, 0 means equal to width. */
|
||||||
|
uint32_t size_with_stride; /* the bytes size of tensor with stride. */
|
||||||
|
|
||||||
|
uint8_t pass_through; /* pass through mode, for rknn_set_io_mem interface.
|
||||||
|
if TRUE, the buf data is passed directly to the input node of the rknn model
|
||||||
|
without any conversion. the following variables do not need to be set.
|
||||||
|
if FALSE, the buf data is converted into an input consistent with the model
|
||||||
|
according to the following type and fmt. so the following variables
|
||||||
|
need to be set.*/
|
||||||
|
uint32_t h_stride; /* the stride along the height dimention of input,
|
||||||
|
Note: it is write-only, if it was set to 0, h_stride = height. */
|
||||||
|
} rknn_tensor_attr;
|
||||||
|
|
||||||
|
typedef struct _rknn_input_range {
|
||||||
|
uint32_t index; /* input parameter, the index of input/output tensor,
|
||||||
|
need set before call rknn_query. */
|
||||||
|
uint32_t shape_number; /* the number of shape. */
|
||||||
|
rknn_tensor_format fmt; /* the data format of tensor. */
|
||||||
|
char name[RKNN_MAX_NAME_LEN]; /* the name of tensor. */
|
||||||
|
uint32_t dyn_range[RKNN_MAX_DYNAMIC_SHAPE_NUM][RKNN_MAX_DIMS]; /* the dynamic input dimensions range. */
|
||||||
|
uint32_t n_dims; /* the number of dimensions. */
|
||||||
|
|
||||||
|
} rknn_input_range;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the information for RKNN_QUERY_PERF_DETAIL.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_perf_detail {
|
||||||
|
char* perf_data; /* the string pointer of perf detail. don't need free it by user. */
|
||||||
|
uint64_t data_len; /* the string length. */
|
||||||
|
} rknn_perf_detail;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the information for RKNN_QUERY_PERF_RUN.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_perf_run {
|
||||||
|
int64_t run_duration; /* real inference time (us) */
|
||||||
|
} rknn_perf_run;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the information for RKNN_QUERY_SDK_VERSION.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_sdk_version {
|
||||||
|
char api_version[256]; /* the version of rknn api. */
|
||||||
|
char drv_version[256]; /* the version of rknn driver. */
|
||||||
|
} rknn_sdk_version;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the information for RKNN_QUERY_MEM_SIZE.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_mem_size {
|
||||||
|
uint32_t total_weight_size; /* the weight memory size */
|
||||||
|
uint32_t total_internal_size; /* the internal memory size, exclude inputs/outputs */
|
||||||
|
uint64_t total_dma_allocated_size; /* total dma memory allocated size */
|
||||||
|
uint32_t total_sram_size; /* total system sram size reserved for rknn */
|
||||||
|
uint32_t free_sram_size; /* free system sram size reserved for rknn */
|
||||||
|
uint32_t reserved[10]; /* reserved */
|
||||||
|
} rknn_mem_size;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the information for RKNN_QUERY_CUSTOM_STRING.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_custom_string {
|
||||||
|
char string[1024]; /* the string of custom, lengths max to 1024 bytes */
|
||||||
|
} rknn_custom_string;
|
||||||
|
|
||||||
|
/*
|
||||||
|
The flags of rknn_tensor_mem.
|
||||||
|
*/
|
||||||
|
typedef enum _rknn_tensor_mem_flags {
|
||||||
|
RKNN_TENSOR_MEMORY_FLAGS_ALLOC_INSIDE = 1, /*Used to mark in rknn_destroy_mem() whether it is necessary to release the "mem" pointer itself.
|
||||||
|
If the flag RKNN_TENSOR_MEMORY_FLAGS_ALLOC_INSIDE is set, rknn_destroy_mem() will call free(mem).*/
|
||||||
|
RKNN_TENSOR_MEMORY_FLAGS_FROM_FD = 2, /*Used to mark in rknn_create_mem_from_fd() whether it is necessary to release the "mem" pointer itself.
|
||||||
|
If the flag RKNN_TENSOR_MEMORY_FLAGS_FROM_FD is set, rknn_destroy_mem() will call free(mem).*/
|
||||||
|
RKNN_TENSOR_MEMORY_FLAGS_FROM_PHYS = 3, /*Used to mark in rknn_create_mem_from_phys() whether it is necessary to release the "mem" pointer itself.
|
||||||
|
If the flag RKNN_TENSOR_MEMORY_FLAGS_FROM_PHYS is set, rknn_destroy_mem() will call free(mem).*/
|
||||||
|
RKNN_TENSOR_MEMORY_FLAGS_UNKNOWN
|
||||||
|
} rknn_tensor_mem_flags;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the memory information of tensor.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_tensor_memory {
|
||||||
|
void* virt_addr; /* the virtual address of tensor buffer. */
|
||||||
|
uint64_t phys_addr; /* the physical address of tensor buffer. */
|
||||||
|
int32_t fd; /* the fd of tensor buffer. */
|
||||||
|
int32_t offset; /* indicates the offset of the memory. */
|
||||||
|
uint32_t size; /* the size of tensor buffer. */
|
||||||
|
uint32_t flags; /* the flags of tensor buffer, reserved */
|
||||||
|
void * priv_data; /* the private data of tensor buffer. */
|
||||||
|
} rknn_tensor_mem;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the input information for rknn_input_set.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_input {
|
||||||
|
uint32_t index; /* the input index. */
|
||||||
|
void* buf; /* the input buf for index. */
|
||||||
|
uint32_t size; /* the size of input buf. */
|
||||||
|
uint8_t pass_through; /* pass through mode.
|
||||||
|
if TRUE, the buf data is passed directly to the input node of the rknn model
|
||||||
|
without any conversion. the following variables do not need to be set.
|
||||||
|
if FALSE, the buf data is converted into an input consistent with the model
|
||||||
|
according to the following type and fmt. so the following variables
|
||||||
|
need to be set.*/
|
||||||
|
rknn_tensor_type type; /* the data type of input buf. */
|
||||||
|
rknn_tensor_format fmt; /* the data format of input buf.
|
||||||
|
currently the internal input format of NPU is NCHW by default.
|
||||||
|
so entering NCHW data can avoid the format conversion in the driver. */
|
||||||
|
} rknn_input;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the output information for rknn_outputs_get.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_output {
|
||||||
|
uint8_t want_float; /* want transfer output data to float */
|
||||||
|
uint8_t is_prealloc; /* whether buf is pre-allocated.
|
||||||
|
if TRUE, the following variables need to be set.
|
||||||
|
if FALSE, the following variables do not need to be set. */
|
||||||
|
uint32_t index; /* the output index. */
|
||||||
|
void* buf; /* the output buf for index.
|
||||||
|
when is_prealloc = FALSE and rknn_outputs_release called,
|
||||||
|
this buf pointer will be free and don't use it anymore. */
|
||||||
|
uint32_t size; /* the size of output buf. */
|
||||||
|
} rknn_output;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the extend information for rknn_init.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_init_extend {
|
||||||
|
rknn_context ctx; /* rknn context */
|
||||||
|
int32_t real_model_offset; /* real rknn model file offset, only valid when init context with rknn file path */
|
||||||
|
uint32_t real_model_size; /* real rknn model file size, only valid when init context with rknn file path */
|
||||||
|
uint8_t reserved[120]; /* reserved */
|
||||||
|
} rknn_init_extend;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the extend information for rknn_run.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_run_extend {
|
||||||
|
uint64_t frame_id; /* output parameter, indicate current frame id of run. */
|
||||||
|
int32_t non_block; /* block flag of run, 0 is block else 1 is non block */
|
||||||
|
int32_t timeout_ms; /* timeout for block mode, in milliseconds */
|
||||||
|
int32_t fence_fd; /* fence fd from other unit */
|
||||||
|
} rknn_run_extend;
|
||||||
|
|
||||||
|
/*
|
||||||
|
the extend information for rknn_outputs_get.
|
||||||
|
*/
|
||||||
|
typedef struct _rknn_output_extend {
|
||||||
|
uint64_t frame_id; /* output parameter, indicate the frame id of outputs, corresponds to
|
||||||
|
struct rknn_run_extend.frame_id.*/
|
||||||
|
} rknn_output_extend;
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_init
|
||||||
|
|
||||||
|
initial the context and load the rknn model.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context* context the pointer of context handle.
|
||||||
|
void* model if size > 0, pointer to the rknn model, if size = 0, filepath to the rknn model.
|
||||||
|
uint32_t size the size of rknn model.
|
||||||
|
uint32_t flag extend flag, see the define of RKNN_FLAG_XXX_XXX.
|
||||||
|
rknn_init_extend* extend the extend information of init.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_init(rknn_context* context, void* model, uint32_t size, uint32_t flag, rknn_init_extend* extend);
|
||||||
|
|
||||||
|
/* rknn_dup_context
|
||||||
|
|
||||||
|
initial the context and load the rknn model.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context* context_in the pointer of context in handle.
|
||||||
|
rknn_context* context_out the pointer of context out handle.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_dup_context(rknn_context* context_in, rknn_context* context_out);
|
||||||
|
|
||||||
|
/* rknn_destroy
|
||||||
|
|
||||||
|
unload the rknn model and destroy the context.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_destroy(rknn_context context);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_query
|
||||||
|
|
||||||
|
query the information about model or others. see rknn_query_cmd.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
rknn_query_cmd cmd the command of query.
|
||||||
|
void* info the buffer point of information.
|
||||||
|
uint32_t size the size of information.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_query(rknn_context context, rknn_query_cmd cmd, void* info, uint32_t size);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_inputs_set
|
||||||
|
|
||||||
|
set inputs information by input index of rknn model.
|
||||||
|
inputs information see rknn_input.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
uint32_t n_inputs the number of inputs.
|
||||||
|
rknn_input inputs[] the arrays of inputs information, see rknn_input.
|
||||||
|
return:
|
||||||
|
int error code
|
||||||
|
*/
|
||||||
|
int rknn_inputs_set(rknn_context context, uint32_t n_inputs, rknn_input inputs[]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
rknn_set_batch_core_num
|
||||||
|
|
||||||
|
set rknn batch core_num.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
int core_num the core number.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
|
||||||
|
*/
|
||||||
|
int rknn_set_batch_core_num(rknn_context context, int core_num);
|
||||||
|
|
||||||
|
/* rknn_set_core_mask
|
||||||
|
|
||||||
|
set rknn core mask.(only supported on RK3588 now)
|
||||||
|
|
||||||
|
RKNN_NPU_CORE_AUTO: auto mode, default value
|
||||||
|
RKNN_NPU_CORE_0: core 0 mode
|
||||||
|
RKNN_NPU_CORE_1: core 1 mode
|
||||||
|
RKNN_NPU_CORE_2: core 2 mode
|
||||||
|
RKNN_NPU_CORE_0_1: combine core 0/1 mode
|
||||||
|
RKNN_NPU_CORE_0_1_2: combine core 0/1/2 mode
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
rknn_core_mask core_mask the core mask.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_set_core_mask(rknn_context context, rknn_core_mask core_mask);
|
||||||
|
|
||||||
|
/* rknn_run
|
||||||
|
|
||||||
|
run the model to execute inference.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
rknn_run_extend* extend the extend information of run.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_run(rknn_context context, rknn_run_extend* extend);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_wait
|
||||||
|
|
||||||
|
wait the model after execute inference.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
rknn_run_extend* extend the extend information of run.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_wait(rknn_context context, rknn_run_extend* extend);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_outputs_get
|
||||||
|
|
||||||
|
wait the inference to finish and get the outputs.
|
||||||
|
this function will block until inference finish.
|
||||||
|
the results will set to outputs[].
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
uint32_t n_outputs the number of outputs.
|
||||||
|
rknn_output outputs[] the arrays of output, see rknn_output.
|
||||||
|
rknn_output_extend* the extend information of output.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_outputs_get(rknn_context context, uint32_t n_outputs, rknn_output outputs[], rknn_output_extend* extend);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_outputs_release
|
||||||
|
|
||||||
|
release the outputs that get by rknn_outputs_get.
|
||||||
|
after called, the rknn_output[x].buf get from rknn_outputs_get will
|
||||||
|
also be free when rknn_output[x].is_prealloc = FALSE.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context context the handle of context.
|
||||||
|
uint32_t n_ouputs the number of outputs.
|
||||||
|
rknn_output outputs[] the arrays of output.
|
||||||
|
return:
|
||||||
|
int error code
|
||||||
|
*/
|
||||||
|
int rknn_outputs_release(rknn_context context, uint32_t n_ouputs, rknn_output outputs[]);
|
||||||
|
|
||||||
|
|
||||||
|
/* new api for zero copy */
|
||||||
|
|
||||||
|
/* rknn_create_mem_from_phys (memory allocated outside)
|
||||||
|
|
||||||
|
initialize tensor memory from physical address.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
uint64_t phys_addr physical address.
|
||||||
|
void *virt_addr virtual address.
|
||||||
|
uint32_t size the size of tensor buffer.
|
||||||
|
return:
|
||||||
|
rknn_tensor_mem the pointer of tensor memory information.
|
||||||
|
*/
|
||||||
|
rknn_tensor_mem* rknn_create_mem_from_phys(rknn_context ctx, uint64_t phys_addr, void *virt_addr, uint32_t size);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_create_mem_from_fd (memory allocated outside)
|
||||||
|
|
||||||
|
initialize tensor memory from file description.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
int32_t fd file description.
|
||||||
|
void *virt_addr virtual address.
|
||||||
|
uint32_t size the size of tensor buffer.
|
||||||
|
int32_t offset indicates the offset of the memory (virt_addr without offset).
|
||||||
|
return:
|
||||||
|
rknn_tensor_mem the pointer of tensor memory information.
|
||||||
|
*/
|
||||||
|
rknn_tensor_mem* rknn_create_mem_from_fd(rknn_context ctx, int32_t fd, void *virt_addr, uint32_t size, int32_t offset);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_create_mem_from_mb_blk (memory allocated outside)
|
||||||
|
|
||||||
|
create tensor memory from mb_blk.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
void *mb_blk mb_blk allocate from system api.
|
||||||
|
int32_t offset indicates the offset of the memory.
|
||||||
|
return:
|
||||||
|
rknn_tensor_mem the pointer of tensor memory information.
|
||||||
|
*/
|
||||||
|
rknn_tensor_mem* rknn_create_mem_from_mb_blk(rknn_context ctx, void *mb_blk, int32_t offset);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_create_mem (memory allocated inside)
|
||||||
|
|
||||||
|
create tensor memory.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
uint32_t size the size of tensor buffer.
|
||||||
|
return:
|
||||||
|
rknn_tensor_mem the pointer of tensor memory information.
|
||||||
|
*/
|
||||||
|
rknn_tensor_mem* rknn_create_mem(rknn_context ctx, uint32_t size);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_destroy_mem (support allocate inside and outside)
|
||||||
|
|
||||||
|
destroy tensor memory.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
rknn_tensor_mem *mem the pointer of tensor memory information.
|
||||||
|
return:
|
||||||
|
int error code
|
||||||
|
*/
|
||||||
|
int rknn_destroy_mem(rknn_context ctx, rknn_tensor_mem *mem);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_set_weight_mem
|
||||||
|
|
||||||
|
set the weight memory.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
rknn_tensor_mem *mem the array of tensor memory information
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_set_weight_mem(rknn_context ctx, rknn_tensor_mem *mem);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_set_internal_mem
|
||||||
|
|
||||||
|
set the internal memory.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
rknn_tensor_mem *mem the array of tensor memory information
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_set_internal_mem(rknn_context ctx, rknn_tensor_mem *mem);
|
||||||
|
|
||||||
|
|
||||||
|
/* rknn_set_io_mem
|
||||||
|
|
||||||
|
set the input and output tensors buffer.
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
rknn_tensor_mem *mem the array of tensor memory information.
|
||||||
|
rknn_tensor_attr *attr the attribute of input or output tensor buffer.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_set_io_mem(rknn_context ctx, rknn_tensor_mem *mem, rknn_tensor_attr *attr);
|
||||||
|
|
||||||
|
/* rknn_set_input_shape(deprecated)
|
||||||
|
|
||||||
|
set the input tensor shape (only valid for dynamic shape rknn model).
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
rknn_tensor_attr *attr the attribute of input or output tensor buffer.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_set_input_shape(rknn_context ctx, rknn_tensor_attr* attr);
|
||||||
|
|
||||||
|
/* rknn_set_input_shapes
|
||||||
|
|
||||||
|
set all the input tensor shapes. graph will run under current set of input shapes after rknn_set_input_shapes.(only valid for dynamic shape rknn model).
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_context ctx the handle of context.
|
||||||
|
uint32_t n_inputs the number of inputs.
|
||||||
|
rknn_tensor_attr attr[] the attribute array of all input tensors.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_set_input_shapes(rknn_context ctx, uint32_t n_inputs, rknn_tensor_attr attr[]);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} //extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //_RKNN_API_H
|
|
@ -0,0 +1,261 @@
|
||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 - 2018 by Rockchip Corp. All rights reserved.
|
||||||
|
*
|
||||||
|
* The material in this file is confidential and contains trade secrets
|
||||||
|
* of Rockchip Corporation. This is proprietary information owned by
|
||||||
|
* Rockchip Corporation. No part of this work may be disclosed,
|
||||||
|
* reproduced, copied, transmitted, or used in any way for any purpose,
|
||||||
|
* without the express written permission of Rockchip Corporation.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _RKNN_MATMUL_API_H
|
||||||
|
#define _RKNN_MATMUL_API_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "rknn_api.h"
|
||||||
|
|
||||||
|
typedef rknn_context rknn_matmul_ctx;
|
||||||
|
|
||||||
|
typedef struct _rknn_matmul_tensor_attr
|
||||||
|
{
|
||||||
|
char name[RKNN_MAX_NAME_LEN];
|
||||||
|
|
||||||
|
// indicate A(M, K) or B(K, N) or C(M, N)
|
||||||
|
uint32_t n_dims;
|
||||||
|
uint32_t dims[RKNN_MAX_DIMS];
|
||||||
|
|
||||||
|
// matmul tensor size
|
||||||
|
uint32_t size;
|
||||||
|
|
||||||
|
// matmul tensor data type
|
||||||
|
// int8 : A, B
|
||||||
|
// int32: C
|
||||||
|
rknn_tensor_type type;
|
||||||
|
} rknn_matmul_tensor_attr;
|
||||||
|
|
||||||
|
typedef struct _rknn_matmul_io_attr
|
||||||
|
{
|
||||||
|
// indicate A(M, K) or B(K, N) or C(M, N)
|
||||||
|
rknn_matmul_tensor_attr A;
|
||||||
|
rknn_matmul_tensor_attr B;
|
||||||
|
rknn_matmul_tensor_attr C;
|
||||||
|
} rknn_matmul_io_attr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
matmul information struct
|
||||||
|
*/
|
||||||
|
typedef struct rknn_matmul_info_t
|
||||||
|
{
|
||||||
|
int32_t M;
|
||||||
|
int32_t K; // limit: rk356x: int8 type must be aligned with 32byte, float16 type must be aligned with 16byte;
|
||||||
|
// rk3588: int8 type must be aligned with 32byte, float16 type must be aligned with 32byte;
|
||||||
|
int32_t N; // limit: rk356x: int8 type must be aligned with 16byte, float16 type must be aligned with 8byte;
|
||||||
|
// rk3588: int8 type must be aligned with 32byte, float16 type must be aligned with 16byte;
|
||||||
|
|
||||||
|
// matmul data type
|
||||||
|
// int8: int8(A) x int8(B) -> int32(C)
|
||||||
|
// float16: float16(A) x float16(B) -> float32(C)
|
||||||
|
rknn_tensor_type type;
|
||||||
|
|
||||||
|
// matmul native layout for B
|
||||||
|
// 0: normal layout
|
||||||
|
// 1: native layout
|
||||||
|
int32_t native_layout;
|
||||||
|
|
||||||
|
// matmul perf layout for A and C
|
||||||
|
// 0: normal layout
|
||||||
|
// 1: perf layout
|
||||||
|
int32_t perf_layout;
|
||||||
|
} rknn_matmul_info;
|
||||||
|
|
||||||
|
/* rknn_matmul_create
|
||||||
|
|
||||||
|
params:
|
||||||
|
rknn_matmul_ctx *ctx the handle of context.
|
||||||
|
rknn_matmul_info *info the matmal information.
|
||||||
|
rknn_matmul_io_attr *io_attr inputs/output attribute
|
||||||
|
return:
|
||||||
|
int error code
|
||||||
|
*/
|
||||||
|
int rknn_matmul_create(rknn_matmul_ctx* ctx, rknn_matmul_info* info, rknn_matmul_io_attr* io_attr);
|
||||||
|
|
||||||
|
/* rknn_matmul_set_io_mem
|
||||||
|
|
||||||
|
params:
|
||||||
|
rknn_matmul_ctx ctx the handle of context.
|
||||||
|
rknn_tensor_mem *mem the pointer of tensor memory information.
|
||||||
|
rknn_matmul_tensor_attr *attr the attribute of input or output tensor buffer.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
|
||||||
|
formula:
|
||||||
|
C = A * B,
|
||||||
|
|
||||||
|
limit:
|
||||||
|
K <= 4096
|
||||||
|
K limit: rk356x: int8 type must be aligned with 32byte, float16 type must be aligned with 16byte;
|
||||||
|
rk3588: int8 type must be aligned with 32byte, float16 type must be aligned with 32byte;
|
||||||
|
N limit: rk356x: int8 type must be aligned with 16byte, float16 type must be aligned with 8byte;
|
||||||
|
rk3588: int8 type must be aligned with 32byte, float16 type must be aligned with 16byte;
|
||||||
|
|
||||||
|
A shape: M x K
|
||||||
|
normal layout: (M, K)
|
||||||
|
[M1K1, M1K2, ..., M1Kk,
|
||||||
|
M2K1, M2K2, ..., M2Kk,
|
||||||
|
...
|
||||||
|
MmK1, MmK2, ..., MmKk]
|
||||||
|
for rk356x:
|
||||||
|
int8:
|
||||||
|
perf layout: (K / 8, M, 8)
|
||||||
|
[K1M1, K2M1, ..., K8M1,
|
||||||
|
K9M2, K10M2, ..., K16M2,
|
||||||
|
...
|
||||||
|
K(k-7)Mm, K(k-6)Mm, ..., KkMm]
|
||||||
|
float16:
|
||||||
|
perf layout: (K / 4, M, 4)
|
||||||
|
[K1M1, K2M1, ..., K4M1,
|
||||||
|
K9M2, K10M2, ..., K8M2,
|
||||||
|
...
|
||||||
|
K(k-3)Mm, K(k-2)Mm, ..., KkMm]
|
||||||
|
for rk3588:
|
||||||
|
int8:
|
||||||
|
perf layout: (K / 16, M, 16)
|
||||||
|
[K1M1, K2M1, ..., K16M1,
|
||||||
|
K9M2, K10M2, ..., K32M2,
|
||||||
|
...
|
||||||
|
K(k-15)Mm, K(k-14)Mm, ..., KkMm]
|
||||||
|
float16:
|
||||||
|
perf layout: (K / 8, M, 8)
|
||||||
|
[K1M1, K2M1, ..., K8M1,
|
||||||
|
K9M2, K10M2, ..., K16M2,
|
||||||
|
...
|
||||||
|
K(k-7)Mm, K(k-6)Mm, ..., KkMm]
|
||||||
|
B shape: K x N
|
||||||
|
normal layout: (K, N)
|
||||||
|
[K1N1, K1N2, ..., K1Nn,
|
||||||
|
K2N1, K2N2, ..., K2Nn,
|
||||||
|
...
|
||||||
|
KkN1, KkN2, ..., KkNn]
|
||||||
|
for rk356x:
|
||||||
|
int8:
|
||||||
|
native layout: (N / 16, K / 32, 16, 32)
|
||||||
|
[K1N1, K2N1, ..., K32N1,
|
||||||
|
K1N2, K2N2, ..., K32N2,
|
||||||
|
...
|
||||||
|
K1N16, K2N16, ..., K32N16,
|
||||||
|
K33N1, K34N1, ..., K64N1,
|
||||||
|
K33N2, K34N2, ..., K64N2,
|
||||||
|
...
|
||||||
|
K(k-31)N16, K(k-30)N16, ..., KkN16,
|
||||||
|
K1N17, K2N17, ..., K32N17,
|
||||||
|
K1N18, K2N18, ..., K32N18,
|
||||||
|
...
|
||||||
|
K(k-31)Nn, K(k-30)Nn, ..., KkNn]
|
||||||
|
float16:
|
||||||
|
native layout: (N / 8, K / 16, 8, 16)
|
||||||
|
[K1N1, K2N1, ..., K16N1,
|
||||||
|
K1N2, K2N2, ..., K16N2,
|
||||||
|
...
|
||||||
|
K1N8, K2N8, ..., K16N8,
|
||||||
|
K17N1, K18N1, ..., K32N1,
|
||||||
|
K17N2, K18N2, ..., K32N2,
|
||||||
|
...
|
||||||
|
K(k-15)N8, K(k-30)N8, ..., KkN8,
|
||||||
|
K1N9, K2N9, ..., K16N9,
|
||||||
|
K1N10, K2N10, ..., K16N10,
|
||||||
|
...
|
||||||
|
K(k-15)Nn, K(k-14)Nn, ..., KkNn]
|
||||||
|
for rk3588:
|
||||||
|
int8:
|
||||||
|
native layout: (N / 32, K / 32, 32, 32)
|
||||||
|
[K1N1, K2N1, ..., K32N1,
|
||||||
|
K1N2, K2N2, ..., K32N2,
|
||||||
|
...
|
||||||
|
K1N32, K2N32, ..., K32N32,
|
||||||
|
K33N1, K34N1, ..., K64N1,
|
||||||
|
K33N2, K34N2, ..., K64N2,
|
||||||
|
...
|
||||||
|
K(k-31)N32, K(k-30)N32, ..., KkN32,
|
||||||
|
K1N33, K2N33, ..., K32N33,
|
||||||
|
K1N34, K2N34, ..., K32N34,
|
||||||
|
...
|
||||||
|
K(k-31)Nn, K(k-30)Nn, ..., KkNn]
|
||||||
|
float16:
|
||||||
|
native layout: (N / 16, K / 32, 16, 32)
|
||||||
|
[K1N1, K2N1, ..., K32N1,
|
||||||
|
K1N2, K2N2, ..., K32N2,
|
||||||
|
...
|
||||||
|
K1N16, K2N16, ..., K32N16,
|
||||||
|
K33N1, K34N1, ..., K64N1,
|
||||||
|
K33N2, K34N2, ..., K64N2,
|
||||||
|
...
|
||||||
|
K(k-31)N16, K(k-30)N16, ..., KkN16,
|
||||||
|
K1N17, K2N17, ..., K32N17,
|
||||||
|
K1N18, K2N18, ..., K32N18,
|
||||||
|
...
|
||||||
|
K(k-31)Nn, K(k-30)Nn, ..., KkNn]
|
||||||
|
C shape: M x N
|
||||||
|
normal layout: (M, N)
|
||||||
|
[M1N1, M1N2, ..., M1Nn,
|
||||||
|
M2N1, M2N2, ..., M2Nn,
|
||||||
|
...
|
||||||
|
MmN1, MmN2, ..., MmNn]
|
||||||
|
perf layout: (N / 4, M, 4)
|
||||||
|
[N1M1, N2M1, ..., N4M1,
|
||||||
|
N5M2, N6M2, ..., N8M2,
|
||||||
|
...
|
||||||
|
N(n-3)Mm, N(n-2)Mm, ..., NnMm]
|
||||||
|
*/
|
||||||
|
int rknn_matmul_set_io_mem(rknn_matmul_ctx ctx, rknn_tensor_mem* mem, rknn_matmul_tensor_attr* attr);
|
||||||
|
|
||||||
|
/* rknn_matmul_set_core_mask
|
||||||
|
|
||||||
|
set rknn core mask.(only support rk3588 in current)
|
||||||
|
|
||||||
|
RKNN_NPU_CORE_AUTO: auto mode, default value
|
||||||
|
RKNN_NPU_CORE_0: core 0 mode
|
||||||
|
RKNN_NPU_CORE_1: core 1 mode
|
||||||
|
RKNN_NPU_CORE_2: core 2 mode
|
||||||
|
RKNN_NPU_CORE_0_1: combine core 0/1 mode
|
||||||
|
RKNN_NPU_CORE_0_1_2: combine core 0/1/2 mode
|
||||||
|
|
||||||
|
input:
|
||||||
|
rknn_matmul_ctx context the handle of context.
|
||||||
|
rknn_core_mask core_mask the core mask.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_matmul_set_core_mask(rknn_matmul_ctx context, rknn_core_mask core_mask);
|
||||||
|
|
||||||
|
/* rknn_matmul_run
|
||||||
|
|
||||||
|
run the matmul in blocking mode
|
||||||
|
|
||||||
|
params:
|
||||||
|
rknn_matmul_ctx ctx the handle of context.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_matmul_run(rknn_matmul_ctx ctx);
|
||||||
|
|
||||||
|
/* rknn_matmul_destroy
|
||||||
|
|
||||||
|
destroy the matmul context
|
||||||
|
|
||||||
|
params:
|
||||||
|
rknn_matmul_ctx ctx the handle of context.
|
||||||
|
return:
|
||||||
|
int error code.
|
||||||
|
*/
|
||||||
|
int rknn_matmul_destroy(rknn_matmul_ctx ctx);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _RKNN_MATMUL_API_H
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
killall start_rknn.sh > /dev/null 2>&1
|
||||||
|
killall rknn_server > /dev/null 2>&1
|
||||||
|
start_rknn.sh &
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
sleep 1
|
||||||
|
rknn_server #>/dev/null 2>&1
|
||||||
|
done
|
|
@ -0,0 +1,9 @@
|
||||||
|
#on early-boot
|
||||||
|
on init
|
||||||
|
start rknn_server
|
||||||
|
|
||||||
|
|
||||||
|
service rknn_server /vendor/bin/rknn_server
|
||||||
|
class core
|
||||||
|
seclabel u:r:rknn_server:s0
|
||||||
|
disabled
|
Loading…
Reference in New Issue