当前位置: 动力学知识库 > 问答 > 编程问答 >

android - setOnFocusChangeListener is not getting called

问题描述:

I am working with OpenCV4Android version 2.4.11 and I am retrieving frames from the camera to make some image processing on these frames. What I want to do is, when the camera focuses I should start the image processing step. to do

so, I used

mOpenCvCameraView.setOnFocusChangeListener

but the problem is, when the app starts the camera starts previewing and despite the camera focus changes, the onFocusChange method is never called also the Log messages inside the setOnFocusChangeListener are never called as well.

please let me know why the setOnFocusChangeListener is not getting called

code:

mOpenCvCameraView.enableView();

mOpenCvCameraView.setOnFocusChangeListener(new View.OnFocusChangeListener() {

@Override

public void onFocusChange(View v, boolean hasFocus) {

Log.w(TAG, "hasFocus: " + hasFocus);

if (hasFocus) {

Log.w(TAG, "hasFocus: " + hasFocus);

mCornersCord = mCornerDetector.findCornersCords(mMatInputFrame);

}

}

});

layout:

<org.opencv.android.JavaCameraView

android:id="@+id/surfaceView"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight=".3"

android:visibility="visible"

opencv:camera_id="any"

opencv:show_fps="true" />

<ImageView

android:id="@+id/fragOpenCvCam_imageView_edges"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight=".3"

android:padding="7dp" />

分享给朋友:
您可能感兴趣的文章:
随机阅读: