[Streamer] Build python wheel and python API (#1702)

* add setup.py

* fix setup.py

* fix setup.py

* fix setup.py

* fix setup.py

* fix setup.py

* fix setup.py

* fix setup.py

* fix setup.py

* fix setup.py

* add scripts

* fix setup.py

* fix setup.py

* fix setup.py

* fix setup.py

* add pybind interface

* update CMakeLists

* fix CMakeLists

* fix setup.py

* fix setup.py

* fix setup

* fix CMakeLists

* fix CMakeLists

* fix CMakeLists

* fix pybind

* fix pybind

* fix pybind

* fix pybind

* fix CMakeLists

* fix CMakeLists

* fix CMakeLists

* fix CMakeLists

* fix CMakeLists

* fix CMakeLists

* fix CMakeLists

* fix CMakeLists.txt

* fix CMakeLists.txt

* fix CMakeLists

* fix CMakeLists

* fix CMakeLists

* fix process_libraries

* test setup

* fix setup

* fix py wheel build

* add ppyoloe py streamer

* delete annotation, fix form

---------

Co-authored-by: Wang Xinyu <shaywxy@gmail.com>
This commit is contained in:
CoolCola
2023-03-30 14:22:46 +08:00
committed by GitHub
parent c04a3a4e35
commit f4a7008732
13 changed files with 632 additions and 10 deletions

View File

@@ -15,13 +15,19 @@
PROJECT(fd_streamer C CXX) PROJECT(fd_streamer C CXX)
CMAKE_MINIMUM_REQUIRED (VERSION 3.10) CMAKE_MINIMUM_REQUIRED (VERSION 3.10)
if(NOT PY_LIBRARY_NAME)
set(PY_LIBRARY_NAME "fastdeploy_streamer_main")
endif()
option(FASTDEPLOY_INSTALL_DIR "Path of downloaded fastdeploy sdk.") option(FASTDEPLOY_INSTALL_DIR "Path of downloaded fastdeploy sdk.")
option(ENABLE_DEEPSTREAM "Enable NVIDIA DeepStream SDK" ON) option(ENABLE_DEEPSTREAM "Enable NVIDIA DeepStream SDK" ON)
file(GLOB_RECURSE DEPLOY_PYBIND_SRCS ${PROJECT_SOURCE_DIR}/src/pybind/*.cc ${PROJECT_SOURCE_DIR}/src/*_pybind.cc)
file(GLOB_RECURSE ALL_STREAMER_SRCS ${PROJECT_SOURCE_DIR}/src/*.cc) file(GLOB_RECURSE ALL_STREAMER_SRCS ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB_RECURSE DEEPSTREAM_SRCS ${PROJECT_SOURCE_DIR}/src/deepstream/*.cc) file(GLOB_RECURSE DEEPSTREAM_SRCS ${PROJECT_SOURCE_DIR}/src/deepstream/*.cc)
file(GLOB_RECURSE PLUGIN_SRCS ${PROJECT_SOURCE_DIR}/src/gstreamer/plugin/*.cc) file(GLOB_RECURSE PLUGIN_SRCS ${PROJECT_SOURCE_DIR}/src/gstreamer/plugin/*.cc)
list(REMOVE_ITEM ALL_STREAMER_SRCS ${DEEPSTREAM_SRCS}) list(REMOVE_ITEM ALL_STREAMER_SRCS ${DEEPSTREAM_SRCS})
list(REMOVE_ITEM ALL_STREAMER_SRCS ${DEPLOY_PYBIND_SRCS})
list(REMOVE_ITEM ALL_STREAMER_SRCS ${PLUGIN_SRCS}) list(REMOVE_ITEM ALL_STREAMER_SRCS ${PLUGIN_SRCS})
set(DEPEND_LIBS "") set(DEPEND_LIBS "")
@@ -34,6 +40,7 @@ list(APPEND DEPEND_LIBS ${GST_LIBRARIES})
include(${FASTDEPLOY_INSTALL_DIR}/FastDeploy.cmake) include(${FASTDEPLOY_INSTALL_DIR}/FastDeploy.cmake)
include_directories(${FASTDEPLOY_INCS}) include_directories(${FASTDEPLOY_INCS})
include_directories(${PROJECT_SOURCE_DIR}/src/) include_directories(${PROJECT_SOURCE_DIR}/src/)
#include_directories(${PROJECT_SOURCE_DIR}/../third_party/pybind11/include/)
if(ENABLE_DEEPSTREAM) if(ENABLE_DEEPSTREAM)
add_definitions(-DENABLE_DEEPSTREAM) add_definitions(-DENABLE_DEEPSTREAM)
@@ -48,9 +55,51 @@ endif()
# If we link multiple yaml-cpp libs, strange error will occur. # If we link multiple yaml-cpp libs, strange error will occur.
list(APPEND DEPEND_LIBS yaml-cpp) list(APPEND DEPEND_LIBS yaml-cpp)
add_library(fd_streamer SHARED ${ALL_STREAMER_SRCS}) add_library(fd_streamer SHARED ${ALL_STREAMER_SRCS} ${ALL_DEPLOY_SRCS})
target_link_libraries(fd_streamer ${FASTDEPLOY_LIBS} ${DEPEND_LIBS}) target_link_libraries(fd_streamer ${FASTDEPLOY_LIBS} ${DEPEND_LIBS})
############################### Building: FastDeploy Python Wheel #############################
if(BUILD_FDSTREAMER_PYTHON)
add_definitions(-DBUILD_FDSTREAMER_PYTHON)
if("${PY_EXT_SUFFIX}" STREQUAL "")
set(PY_EXT_SUFFIX ".so")
endif()
# find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12
# Use the following command in the future; now this is only compatible with the latest pybind11
# find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED)
find_package(PythonInterp ${PY_VERSION} REQUIRED)
find_package(PythonLibs ${PY_VERSION})
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
endif()
message(STATUS "pybind srcs: ${DEPLOY_PYBIND_SRCS}")
add_library(${PY_LIBRARY_NAME} MODULE ${DEPLOY_PYBIND_SRCS})
redefine_file_macro(${PY_LIBRARY_NAME})
set_target_properties(${PY_LIBRARY_NAME} PROPERTIES PREFIX "")
set_target_properties(${PY_LIBRARY_NAME}
PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
set_target_properties(${PY_LIBRARY_NAME} PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
set_target_properties(${PY_LIBRARY_NAME}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
target_include_directories(${PY_LIBRARY_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
${PYTHON_INCLUDE_DIR})
target_include_directories(${PY_LIBRARY_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/../third_party/pybind11/include)
# target_include_directories(${PY_LIBRARY_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/../third_party/dlpack/include)
target_link_libraries(${PY_LIBRARY_NAME} PUBLIC fd_streamer)
file(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/python/streamer/libs)
file(MAKE_DIRECTORY ${PROJECT_SOURCE_DIR}/python/streamer/libs)
add_custom_target(copy_fd_libraries ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/*.so* ${PROJECT_SOURCE_DIR}/python/streamer/libs/ DEPENDS ${PY_LIBRARY_NAME})
endif(BUILD_FDSTREAMER_PYTHON)
add_subdirectory(src/gstreamer/meta) add_subdirectory(src/gstreamer/meta)
add_subdirectory(src/gstreamer/plugin/fdinfer) add_subdirectory(src/gstreamer/plugin/fdinfer)
add_subdirectory(src/gstreamer/plugin/fdtracker) add_subdirectory(src/gstreamer/plugin/fdtracker)

View File

@@ -0,0 +1,6 @@
from streamer.fd_streamer import FDStreamer
st = FDStreamer('streamer_cfg.yml')
st.Run()

View File

View File

@@ -0,0 +1,72 @@
# Copyright (c) 2020 PaddlePaddle Authors. 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.
import os
import sys
import shutil
import subprocess
import platform
user_specified_dirs = ['@OPENCV_DIRECTORY@', '@ORT_DIRECTORY@', ]
def process_on_linux(current_dir):
rpaths = ["$ORIGIN:$ORIGIN/libs"]
fd_libs = list()
libs_path = os.path.join(current_dir, "streamer", "libs")
for f in os.listdir(libs_path):
filename = os.path.join(libs_path, f)
if not os.path.isfile(filename):
continue
if f.count("fastdeploy") and f.count(".so") > 0:
fd_libs.append(filename)
cmake_build_dir = os.path.join(current_dir, ".setuptools-cmake-build")
for lib in fd_libs:
command = "{} --set-rpath '{}' {}".format(patchelf_bin_path, ":".join(rpaths), lib)
if platform.machine() != 'sw_64' and platform.machine() != 'mips64':
assert subprocess.Popen(
command,
shell=True) != 0, "patchelf {} failed, the command: {}".format(
command, lib)
def get_all_files(dirname):
files = list()
for root, dirs, filenames in os.walk(dirname):
for f in filenames:
fullname = os.path.join(root, f)
files.append(fullname)
return files
def process_libraries(current_dir):
if platform.system().lower() == "linux":
process_on_linux(current_dir)
elif platform.system().lower() == "darwin":
process_on_mac(current_dir)
elif platform.system().lower() == "windows":
process_on_windows(current_dir)
all_files = get_all_files(os.path.join(current_dir, "streamer", "libs"))
package_data = list()
filters = [".vcxproj", ".png", ".java", ".h", ".cc", ".cpp", ".hpp"]
for f in all_files:
remain = True
if remain:
package_data.append(
os.path.relpath(f, os.path.join(current_dir, "streamer")))
return package_data

348
streamer/python/setup.py Normal file
View File

@@ -0,0 +1,348 @@
# Copyright (c) 2020 PaddlePaddle Authors. 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.
# This file refered to github.com/onnx/onnx.git
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import shutil
import os
TOP_DIR = os.path.realpath(os.path.dirname(__file__))
TOP_DIR = os.path.split(TOP_DIR)[0]
PACKAGE_NAME = os.getenv("PACKAGE_NAME", "streamer")
wheel_name = "fastdeploy-streamer-python"
from distutils.spawn import find_executable
from distutils import sysconfig, log
import setuptools
import setuptools.command.build_py
import setuptools.command.develop
import setuptools.command.build_ext
from collections import namedtuple
from contextlib import contextmanager
import glob
import shlex
import subprocess
import sys
import platform
from textwrap import dedent
import multiprocessing
setup_configs = dict()
setup_configs["PY_LIBRARY_NAME"] = "fastdeploy" + PACKAGE_NAME + "_main"
print(TOP_DIR, 'top dir--')
SRC_DIR = os.path.join(TOP_DIR, 'python')
PYTHON_SRC_DIR = os.path.join(TOP_DIR, 'python', "streamer")
CMAKE_BUILD_DIR = os.path.join(TOP_DIR, 'python', '.setuptools-cmake-build')
FASTDEPLOY_INSTALL_DIR = os.path.join(TOP_DIR, '../build', 'installed_fastdeploy')
WINDOWS = (os.name == 'nt')
CMAKE = find_executable('cmake3') or find_executable('cmake')
MAKE = find_executable('make')
setup_requires = []
extras_require = {}
################################################################################
# Version
################################################################################
try:
git_version = subprocess.check_output(
['git', 'rev-parse', 'HEAD'], cwd=TOP_DIR).decode('ascii').strip()
except (OSError, subprocess.CalledProcessError):
git_version = None
with open(os.path.join(TOP_DIR, '..', 'VERSION_NUMBER')) as version_file:
VersionInfo = namedtuple('VersionInfo', ['version', 'git_version'])(
version=version_file.read().strip(), git_version=git_version)
################################################################################
# Pre Check
################################################################################
assert CMAKE, 'Could not find "cmake" executable!'
################################################################################
# Utilities
################################################################################
@contextmanager
def cd(path):
if not os.path.isabs(path):
raise RuntimeError('Can only cd to absolute path, got: {}'.format(path))
orig_path = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(orig_path)
################################################################################
# Customized commands
################################################################################
class ONNXCommand(setuptools.Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def get_all_files(dirname):
files = list()
for root, dirs, filenames in os.walk(dirname):
for f in filenames:
fullname = os.path.join(root, f)
files.append(fullname)
return files
class create_version(ONNXCommand):
def run(self):
with open(os.path.join(PYTHON_SRC_DIR, 'code_version.py'), 'w') as f:
f.write(
dedent('''\
# This file is generated by setup.py. DO NOT EDIT!
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
version = '{version}'
git_version = '{git_version}'
'''.format(**dict(VersionInfo._asdict()))))
class cmake_build(setuptools.Command):
"""
Compiles everything when `python setupmnm.py build` is run using cmake.
Custom args can be passed to cmake by specifying the `CMAKE_ARGS`
environment variable.
The number of CPUs used by `make` can be specified by passing `-j<ncpus>`
to `setup.py build`. By default all CPUs are used.
"""
user_options = [(str('jobs='), str('j'),
str('Specifies the number of jobs to use with make'))]
built = False
def initialize_options(self):
self.jobs = None
def finalize_options(self):
if sys.version_info[0] >= 3:
self.set_undefined_options('build', ('parallel', 'jobs'))
if self.jobs is None and os.getenv("MAX_JOBS") is not None:
self.jobs = os.getenv("MAX_JOBS")
self.jobs = multiprocessing.cpu_count() if self.jobs is None else int(
self.jobs)
def run(self):
if cmake_build.built:
return
cmake_build.built = True
if not os.path.exists(CMAKE_BUILD_DIR):
os.makedirs(CMAKE_BUILD_DIR)
with cd(CMAKE_BUILD_DIR):
build_type = 'Release'
# configure
cmake_args = [
CMAKE,
'-DPYTHON_INCLUDE_DIR={}'.format(sysconfig.get_python_inc()),
'-DPYTHON_EXECUTABLE={}'.format(sys.executable),
'-DBUILD_FDSTREAMER_PYTHON=ON',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
'-DPY_EXT_SUFFIX={}'.format(
sysconfig.get_config_var('EXT_SUFFIX') or ''),
'-DFASTDEPLOY_INSTALL_DIR={}'.format(FASTDEPLOY_INSTALL_DIR),
]
cmake_args.append('-DCMAKE_BUILD_TYPE=%s' % build_type)
for k, v in setup_configs.items():
cmake_args.append("-D{}={}".format(k, v))
if 'CMAKE_ARGS' in os.environ:
extra_cmake_args = shlex.split(os.environ['CMAKE_ARGS'])
# prevent crossfire with downstream scripts
del os.environ['CMAKE_ARGS']
log.info('Extra cmake args: {}'.format(extra_cmake_args))
cmake_args.extend(extra_cmake_args)
cmake_args.append(TOP_DIR)
subprocess.check_call(cmake_args)
build_args = [CMAKE, '--build', os.curdir]
if WINDOWS:
build_args.extend(['--config', build_type])
build_args.extend(['--', '/maxcpucount:{}'.format(self.jobs)])
else:
build_args.extend(['--', '-j', str(self.jobs)])
subprocess.check_call(build_args)
class build_py(setuptools.command.build_py.build_py):
def run(self):
self.run_command('create_version')
self.run_command('cmake_build')
generated_python_files = \
glob.glob(os.path.join(CMAKE_BUILD_DIR, PACKAGE_NAME, '*.py')) + \
glob.glob(os.path.join(CMAKE_BUILD_DIR, PACKAGE_NAME, '*.pyi'))
for src in generated_python_files:
dst = os.path.join(TOP_DIR, os.path.relpath(src, CMAKE_BUILD_DIR))
self.copy_file(src, dst)
return setuptools.command.build_py.build_py.run(self)
class develop(setuptools.command.develop.develop):
def run(self):
self.run_command('build_py')
setuptools.command.develop.develop.run(self)
class build_ext(setuptools.command.build_ext.build_ext):
def run(self):
self.run_command('cmake_build')
setuptools.command.build_ext.build_ext.run(self)
def build_extensions(self):
for ext in self.extensions:
fullname = self.get_ext_fullname(ext.name)
filename = os.path.basename(self.get_ext_filename(fullname))
lib_path = CMAKE_BUILD_DIR
if os.name == 'nt':
debug_lib_dir = os.path.join(lib_path, "Debug")
release_lib_dir = os.path.join(lib_path, "Release")
if os.path.exists(debug_lib_dir):
lib_path = debug_lib_dir
elif os.path.exists(release_lib_dir):
lib_path = release_lib_dir
src = os.path.join(lib_path, filename)
dst = os.path.join(
os.path.realpath(self.build_lib), PACKAGE_NAME, filename)
self.copy_file(src, dst)
class mypy_type_check(ONNXCommand):
description = 'Run MyPy type checker'
def run(self):
"""Run command."""
onnx_script = os.path.realpath(
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"tools/mypy-onnx.py"))
returncode = subprocess.call([sys.executable, onnx_script])
sys.exit(returncode)
cmdclass = {
'create_version': create_version,
'cmake_build': cmake_build,
'build_py': build_py,
'develop': develop,
'build_ext': build_ext,
'typecheck': mypy_type_check,
}
################################################################################
# Extensions
################################################################################
ext_modules = [
setuptools.Extension(
name=str(PACKAGE_NAME + '.' + setup_configs["PY_LIBRARY_NAME"]),
sources=[]),
]
################################################################################
# Packages
################################################################################
# no need to do fancy stuff so far
# if PACKAGE_NAME != "fastdeploy_streamer":
# packages = setuptools.find_packages(exclude=['fastdeploy*', 'scripts'])
# else:
packages = setuptools.find_packages(exclude=['scripts'])
################################################################################
# Test
################################################################################
if sys.version_info[0] == 3:
# Mypy doesn't work with Python 2
extras_require['mypy'] = ['mypy==0.600']
################################################################################
# Final
################################################################################
package_data = {PACKAGE_NAME: []}
if sys.argv[1] == "install" or sys.argv[1] == "bdist_wheel":
from scripts.process_libraries import process_libraries
all_lib_data = process_libraries(
os.path.split(os.path.abspath(__file__))[0])
package_data[PACKAGE_NAME].extend(all_lib_data)
print("Package_data:")
print(all_lib_data)
setuptools.setup(
name=wheel_name,
version=VersionInfo.version,
ext_modules=ext_modules,
description="Deploy Kit Tool For Deeplearning models.",
packages=packages,
package_data=package_data,
include_package_data=True,
setup_requires=setup_requires,
extras_require=extras_require,
author='fastdeploy',
author_email='fastdeploy@baidu.com',
url='https://github.com/PaddlePaddle/FastDeploy.git',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
license='Apache 2.0')
else:
setuptools.setup(
name=wheel_name,
version=VersionInfo.version,
description="Deploy Kit Tool For Deeplearning models.",
ext_modules=ext_modules,
cmdclass=cmdclass,
packages=packages,
package_data=package_data,
include_package_data=False,
setup_requires=setup_requires,
extras_require=extras_require,
author='fastdeploy',
author_email='fastdeploy@baidu.com',
url='https://github.com/PaddlePaddle/FastDeploy.git',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
license='Apache 2.0')

View File

@@ -0,0 +1,5 @@
from __future__ import absolute_import
from . import c_lib_wrap as C

View File

@@ -0,0 +1,24 @@
# Copyright (c) 2022 PaddlePaddle Authors. 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.
from __future__ import absolute_import
import logging
import os
import sys
try:
from .libs.streamer_main import *
except:
raise RuntimeError("FastDeploy Streamer initalized failed!")

View File

@@ -0,0 +1,27 @@
# Copyright (c) 2022 PaddlePaddle Authors. 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.
from __future__ import absolute_import
from . import c_lib_wrap as C
class FDStreamer:
def __init__(self, config_file):
self.streamer = C.FDStreamer()
self.streamer.Init(config_file)
def Run(self):
self.streamer.Run()
def RunAsync(self):
self.streamer.RunAsync()

View File

@@ -0,0 +1,30 @@
// Copyright (c) 2022 PaddlePaddle Authors. 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 "pybind/main.h"
#include "fd_streamer.h"
namespace fastdeploy {
namespace streamer {
void BindFDStreamer(pybind11::module& m) {
pybind11::class_<FDStreamer>(m, "FDStreamer")
.def(pybind11::init<>(), "Default Constructor")
.def("Init", [](FDStreamer& self, std::string config_file){
return self.Init(config_file);
})
.def("Run", &FDStreamer::Run)
.def("RunAsync", &FDStreamer::RunAsync);
}
} // namespace streamer
} // namespace fastdeploy

View File

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
file(GLOB_RECURSE ALL_SRCS ${PROJECT_SOURCE_DIR}/*.cc ${PROJECT_SOURCE_DIR}/src/*.cpp) file(GLOB_RECURSE ALL_SRCS ${PROJECT_SOURCE_DIR}/src/gstreamer/plugin/fdtracker/*.cc ${PROJECT_SOURCE_DIR}/src/gstreamer/plugin/fdtracker/*.cpp)
add_library(gstfdtracker SHARED ${ALL_SRCS} ) add_library(gstfdtracker SHARED ${ALL_SRCS} )
target_link_libraries(gstfdtracker ${DEPEND_LIBS} ${FASTDEPLOY_LIBS}) target_link_libraries(gstfdtracker ${DEPEND_LIBS} ${FASTDEPLOY_LIBS})

View File

@@ -25,14 +25,14 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_TYPE_FDTRACKER (gst_fdtracker_get_type()) #define GST_TYPE_FDTRACKER (gst_fdtracker_get_type())
#define GST_FDTRACKER(obj) G_TYPE_CHECK_INSTANCE_CAST(obj) \ #define GST_FDTRACKER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_FDTRACKER, GstFdtracker) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_FDTRACKER, GstFdtracker))
#define GST_FDTRAKERCLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass) \ #define GST_FDTRAKERCLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST(klass), GST_TYPE_FDTRAKERGstFdtrackerClass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_FDTRAKERGstFdtrackerClass))
#define GST_IS_FDTRACKER(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj) \ #define GST_IS_FDTRACKER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE(obj), GST_TYPE_FDTRACKER) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_FDTRACKER))
#define GST_IS_FDTRACKER_CLASS(obj) G_TYPE_CHECK_CLASS_TYPE(klass) \ #define GST_IS_FDTRACKER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE(klass), GST_TYPE_FDTRACKER) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_FDTRACKER))
typedef struct _GstFdtracker GstFdtracker; typedef struct _GstFdtracker GstFdtracker;
typedef struct _GstFdtrackerClass GstFdtrackerClass; typedef struct _GstFdtrackerClass GstFdtrackerClass;

31
streamer/src/pybind/main.cc Executable file
View File

@@ -0,0 +1,31 @@
// Copyright (c) 2022 PaddlePaddle Authors. 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 "pybind/main.h"
namespace fastdeploy {
namespace streamer {
void BindFDStreamer(pybind11::module&);
PYBIND11_MODULE(fastdeploy_streamer_main, m) {
m.doc() =
"Make programer easier to deploy deeplearning model, save time to save "
"the world!";
BindFDStreamer(m);
}
} // namespace streamer
} // namespace fastdeploy

30
streamer/src/pybind/main.h Executable file
View File

@@ -0,0 +1,30 @@
// Copyright (c) 2022 PaddlePaddle Authors. 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.
#pragma once
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/eval.h>
#include <type_traits>
namespace fastdeploy {
namespace streamer {
} // namespace streamer
} // namespace fastdeploy