【发布时间】:2015-01-12 04:40:17
【问题描述】:
我正在尝试在 Java 中实现霍夫变换以查找图像中的所有行。由于该过程本身花费了太多时间,因此我决定将其分散到多个线程中。然而,在这样做之后,这个过程并没有变得更快。我究竟做错了什么? for 循环在每次迭代中等待 input_elements 完成的原因是什么?
for循环
latch = new CountDownLatch(thread_arr.length);
for (int i=0; i<border_que.arr.length; i++) {
thread_arr[i].input_elements(border_que.arr[i][0], border_que.arr[i][1]);
}
try {
latch.await();
} catch (Exception e) {System.out.println(e.getCause());}
线程代码
class RowAndThetaThread implements Runnable{
private int x_0;
private int y_0;
public void run() {
// find rho and theta and push them to an array
}
public void input_elements(int x, int y) {
x_0 = x;
y_0 = y;
this.run();
}
}
【问题讨论】:
标签: java android multithreading hough-transform