-1
이 콜백 메소드 안에 코드를 별도의 스레드에 넣어서이 코드의 처리 속도가 느려지는 것을 막기 위해 실행 속도를 높이고 싶었지만 시도 할 때 컴파일러에서 오류가 발생했습니다. 메서드에서 반환되지 않습니다.값을 반환하는 콜백 메소드 내에서 별도의 스레드를 시작하는 방법은 무엇입니까?
마치 컴파일러가 시작한 새 스레드 외부에 반환을 원하는 것처럼 보입니다.
어떻게 return 메서드에서 코드를 별도의 실행 프로세스로 실행할 수 있습니까?
public Mat onCameraFrame(final CvCameraViewFrame inputFrame) {
new Thread(){
public void run() {
mRgba = inputFrame.rgba();
mGray = inputFrame.gray();
MatOfRect circles = new MatOfRect();
Imgproc.GaussianBlur(mGray, mGray, new Size(5, 5), 2, 2);
Imgproc.HoughCircles(mGray, circles, Imgproc.CV_HOUGH_GRADIENT,
1, mGray.rows()/8, 150, 50, 0, 0);
if (circles.cols() > 0)
for (int x = 0; x < circles.cols(); x++)
{
double vCircle[] = circles.get(0,x);
if (vCircle == null)
break;
Point pt = new Point(Math.round(vCircle[0]), Math.round(vCircle[1]));
int radius = (int)Math.round(vCircle[2]);
// draw the found circle
Core.circle(mRgba, pt, radius, new Scalar(0,255,0), 7);
Core.circle(mRgba, pt, 3, new Scalar(0,0,255), 7);
}
return mRgba; // <-- complier wants this to be outside of this thread
} // end run
}.start();
} // oncameraframe