我正试图从红色圆圈内部获取颜色,并改变位于左上角的大圆圈的颜色,如screen shot所示。如在屏幕截图中看到的那样,大圆圈的颜色与红色圆圈中的颜色不同,它会从红色圆圈中稍微留下颜色。我给了同样的坐标,如何解决它?
这是我的代码。
public class MainActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2, View.OnTouchListener {
private CameraBridgeViewBase cameraManager;
private BaseLoaderCallback callBack = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
cameraManager.enableView();
}
};
Mat mRgba;
double[] renk;
int r,g,b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(!OpenCVLoader.initDebug()){
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, this, callBack);
}
cameraManager = (CameraBridgeViewBase)findViewById(R.id.kamera);
cameraManager.setVisibility(View.VISIBLE);
cameraManager.setCvCameraViewListener(this);
cameraManager.setCameraIndex(0);
}
@Override
public void onCameraViewStarted(int width, int height) {
mRgba = new Mat(width, height, CvType.CV_8UC4);
}
@Override
public void onCameraViewStopped() {
}
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
renk = mRgba.get(mRgba.width()/2, (mRgba.height()/10)*8);
Imgproc.circle(mRgba, new Point(mRgba.width()/2, (mRgba.height()/10)*8), 10, new Scalar(255,0,0));
r = (int) renk[0];
g = (int) renk[1];
b = (int) renk[2];
Imgproc.circle(mRgba, new Point(0, 0), 100, new Scalar(r,g,b), 100);
return mRgba;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
}
答案 0 :(得分:0)
(代表OP发布)。
我知道那件事。 Point(x,y)=列,行。