我正在使用OpenCV for Python,以下是执行以下步骤后的结果:
正如你所看到的,我的Canny探测器表现非常糟糕,我的面罩中有很多噪音。我尝试过某些技术,包括侵蚀和扩张,但它们没有太多帮助。
我还能做些什么来确保当我将面罩传递给Hough Line Transformer时,它实际上能够检测到球场的边缘?
以下是一些供参考的代码:
public static void main(String[] args) {
int id = 0;
String time = new SimpleDateFormat("DD.MM.YYYY.HH.mm.ss").format(new java.util.Date());
String name = "Tobi";
String address = "Ibari";
String city = "Las Vegas";
String county = "county 1";
String contact = "asdaf@gmail.com";
String description = "Whatever";
double price = 5000.0;
boolean prepaid = true || false;
id++;
//List<Package> packageList = new ArrayList<>();
// Adding packages to the list
//packages.add(new Package(id, time, name, address, city, county, contact, description, price, prepaid));
try (Connection conn = getDBConnection()) {
String sql = "INSERT INTO packages VALUES (?,?,?,?,?,?,?,?)";
PreparedStatement statement = conn.prepareStatement(sql);
statement.setString(1, String.valueOf(id));
statement.setString(2, "arrived");
statement.setString(3, name);
statement.setString(4, address);
statement.setString(5, contact);
statement.setString(6, String.valueOf(price));
statement.setString(7, county);
statement.setString(8, city);
statement.executeQuery();
} catch (SQLException ex) {
Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static Connection getDBConnection() {
Connection dbConnection = null;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.err.println(e.getMessage());
}
try {
dbConnection = DriverManager.getConnection("jdbc:mysql://localhost/stackoverflow", "root", "mysql");
return dbConnection;
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return dbConnection;
}
编辑:我正在尝试复制这项研究:web.stanford.edu/class/ee368/Project_Spring_1415/Reports / ...我希望通过检测勾勒出它的直线来隔离球场,这样我最终可以使用单应法找到球场上球员的坐标。
答案 0 :(得分:1)
在这种情况下,检测图像上的霍夫线是最好的选择,因为球场颜色可能会因地而异以及相机设置发生变化。检测线条以及使用均匀色块进行一些进一步处理应该可以让您准确地对球场区域进行分段。