2d numpy数组的边界框

时间:2019-06-17 04:07:42

标签: python numpy

我正在尝试为图像中的物体检测生成一个边界框。我读取图像并生成一个二进制2d numpy数组,例如:

array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 0, 0],
       [0, 0, 1, 1, 0, 0],
       [0, 0, 1, 1, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0]])

1表示要在图像边框内的像素。如何获得左上角点的x,y坐标,然后是x,y的长度?

1 个答案:

答案 0 :(得分:0)

检查以下简单代码:

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@Configuration
@EnableWebSecurity
@ComponentScan(basePackages = { "au.xyz.myproject" })
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.headers().contentSecurityPolicy("default-src 'none'; worker-src 'self'; connect-src 'self'; font-src 'self';" +
                "img-src 'self'; media-src 'self'; object-src 'self'; script-src 'self'; style-src 'self'");
    }
}