@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
contours = new ArrayList<MatOfPoint>();
hierarchy = new Mat();
Imgproc.GaussianBlur(mRgba,mIntermediateMat,new Size(9,9),2,2);
Imgproc.Canny(mRgba, mIntermediateMat, 80, 100);
Imgproc.findContours(mIntermediateMat, contours, hierarchy, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE, new Point(0, 0));
/* Mat drawing = Mat.zeros( mIntermediateMat.size(), CvType.CV_8UC3 );
for( int i = 0; i< contours.size(); i++ )
{
Scalar color =new Scalar(Math.random()*255, Math.random()*255, Math.random()*255);
Imgproc.drawContours( drawing, contours, i, color, 2, 8, hierarchy, 0, new Point() );
}*/
hierarchy.release();
// Imgproc.cvtColor(mIntermediateMat, mRgba, Imgproc.COLOR_GRAY2RGBA, 4)
/* Mat drawing = Mat.zeros( mIntermediateMat.size(), CvType.CV_8UC3 );
for( int i = 0; i< contours.size(); i++ )
{
Scalar color =new Scalar(Math.random()*255, Math.random()*255, Math.random()*255);
Imgproc.drawContours( drawing, contours, i, color, 2, 8, hierarchy, 0, new Point() );
}*/
for ( int contourIdx=0; contourIdx < contours.size(); contourIdx++ )
{
// Minimum size allowed for consideration
MatOfPoint2f approxCurve = new MatOfPoint2f();
MatOfPoint2f contour2f = new MatOfPoint2f( contours.get(contourIdx).toArray() );
//Processing on mMOP2f1 which is in type MatOfPoint2f
double approxDistance = Imgproc.arcLength(contour2f, true)*0.02;
Imgproc.approxPolyDP(contour2f, approxCurve, approxDistance, true);
//Convert back to MatOfPoint
MatOfPoint points = new MatOfPoint( approxCurve.toArray() );
// Get bounding rect of contour
Rect rect = Imgproc.boundingRect(points);
Core.rectangle(mRgba, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(255, 0, 0, 255), 3);
}
return mRgba;
}
java编译错误。
consumerConfig.subscribe(
regClient -> regClient.onDiscoveryEvent(
Constants.PROVIDER_ADD_EVENT,
ssfurl-> System.out.println(ssfurl))
);
但是当我改为Anonymous class.it worded.why?
感谢。
编译下面的代码,没问题。Error:(172, 72) java: cannot find symbol
symbol: method onDiscoveryEvent(java.lang.String,(ssfurl)->[...]furl))
location: java.lang.Object regClient
ConsumerConfig方法
consumerConfig.subscribe(new Consumer<RegClient>() {
@Override
public void accept(RegClient regClient) {
regClient.onDiscoveryEvent(Constants.PROVIDER_ADD_EVENT, ssfurl -> System.out.println(ssfurl));
}
});
RegClient的方法。
public void onDiscoveryEvent(String eventKey,DiscoveryEvent event)
DiscoverEvent界面
public List<Provider> subscribe(Consumer<RegClient> callback){
List<RegistryConfig> registryConfigs = getRegistries();
if (registryConfigs == null || registryConfigs.isEmpty()){
throw new InitException("reg center address is empty");
}
List<Provider> providers = new ArrayList<>();
for (RegistryConfig config:registryConfigs){
RegClient regClient = RegClientFactory.getRegClient(config.getRegisterAddresses());
List<SSFURL> ssfurls = regClient.subscribe(buildSubscribeURL()).getProviderList();
callback.accept(regClient);
if (ssfurls != null && !ssfurls.isEmpty()){
providers.addAll(getSubscribeProviders(ssfurls));
}
}
return providers;
}