[更新]:已添加屏幕截图.
我在下面的基础教程tutorial-1-camerapreview来自OpenCV的-3.4.1-Android的sdk_4.我想点击屏幕并获得该x y位置的RGB颜色.我得到了HERE的 帮助(在相机预览中从触摸事件中检索精确的RGB值):
获取xy坐标:
@SuppressWarnings("deprecation")
@Override
public boolean onTouchEvent(MotionEvent event) {
x = (int)event.getX();
y = (int)event.getY();
return super.onTouchEvent(event);
}
Run Code Online (Sandbox Code Playgroud)
onCameraFrame为:
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
if(x != -1 && y != -1) { //if this is true, you've touched something
rgb = mRgba.get(x,y);
Log.d(TAG, "Touch coordinates--> " + "x: " + String.valueOf(x)
+ " y: " + String.valueOf(y) + " \n"
+ "RGB values--> …Run Code Online (Sandbox Code Playgroud)