Jetson 共用资料

背景去除

2023-07-25 admin

背景去除

1.简介

背景去除(又称背景减法,或显著对象检测)生成一个遮罩,将图像的前景与背景分割开来。您可以使用它来替换或模糊背景(类似于视频会议应用程序),也可以帮助预处理其他视觉DNN,如对象检测/跟踪或运动检测。所使用的模型是一个完全卷积网络U²-Net。

backgroundNet对象获取图像,并输出前景遮罩。backgroundNet可以从Python和C++中使用。 作为使用backgroundNet类的示例,有C++和Python的示例程序:

2.运行示例

以下是删除和替换图像背景的示例:

构建项目后,请确保您的终端位于aarch64/bin目录中:

cd jetson-inference/build/aarch64/bin

# C++

$ ./backgroundnet images/bird_0.jpg images/test/bird_mask.png  # remove the background (with alpha)

$ ./backgroundnet --replace=images/snow.jpg images/bird_0.jpg images/test/bird_replace.jpg    # replace the background

# Python

$ ./backgroundnet.py images/bird_0.jpg images/test/bird_mask.png       # remove the background (with alpha)

$ ./backgroundnet.py --replace=images/snow.jpg images/bird_0.jpg images/test/bird_replace.jpg # replace the background

--replace命令行参数接受用于替换背景的图像的文件名。它将被重新缩放到与输入相同的分辨率

 

 

3.实时视频

要在实时摄像机流上运行背景删除或替换,请从“摄像机流和多媒体”页面传入设备:

# C++

$ ./backgroundnet /dev/video0   # remove the background

$ ./backgroundnet --replace=images/coral.jpg /dev/video0  # replace the background

# Python

$ ./backgroundnet /dev/video0   # remove the background

$ ./backgroundnet --replace=images/coral.jpg /dev/video0  # replace the background

通过指定输出流,您可以在显示器上(默认设置)、通过网络(与WebRTC类似)查看,或将其保存到视频文件中

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


首页
产品
案例
联系