Summary
How does the imageProxy parameter in this lambda expression within Google's MLKit Vision example code get defined?
Details
I understand the basic concepts of lamda expressions, such as those given in the w3schools examples, and more detailed examples given by the Oracle examples but I am struggling to understand how the quoted one from the MLKit is resolved for the following reasons as it seemingly differs from the other examples:
- There is no variable declaration associated with analysisUseCase.setAnalyzer, like with the two last examples from the w3schools link above. So I don't know how imageProxy would be defined elsewhere via a call to some variable as there is no variable to refer to.
- According to the javadoc comments on setAnalyzer, the two parameters for analysisUseCase.setAnalyzer should be
setAnalyzer(@NonNull Executor executor, @NonNull Analyzer analyzer)
. Unless an Analyzer object is some kind of Consumer, I see no relation to the first example in w3schools. Furthermore, it is my understanding that this would imply the lamda expression should return such an Analyzer object, but there is no return statement.
Furthermore, Android Studio's tooltip for it shows that it resolves to androidx.camera.core.ImageProxy imageProxy
. How does the linter know how to resolve this?
The underlying question as to why I want to know this is that I am modifying this sample code and want access to the imageProxy.getWidth()
method elsewhere in my code. Without understanding the lamda expressions, I am not sure how to access this object and associated method.