如何在Mat对象中插入一行或一个矩形(openCV)

时间:2013-06-13 01:42:27

标签: java android opencv

我的类实现CVCameraListener接口,该接口有一个方法onCameraFrame(),它返回Mat对象,该对象将显示在手机的屏幕上。(此方法返回您在手机屏幕上看到的内容)

如何在此Mat对象中插入一行?例如,我想从(x1,y1)到(x2,y2)画线。在Swing我会做:`g.drawLine(x1,y1,x2,y2)

方法:

public Mat onCameraFrame(Mat inputFrame) {
        inputFrame.copyTo(mRgba);      
        return mRgba;
    }

2 个答案:

答案 0 :(得分:4)

您可以使用Imgproc.rectangle方法绘制矩形。

Imgproc.rectangle(SrcMat, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), Detect_Color, 5);

SrcMat是你的源码和你的输出, 第一点是矩形的起点, 最后一点是矩形的终点, Detect_Color就像new Scalar(0, 255, 0, 255);那样的标量 5是矩形的厚度

答案 1 :(得分:1)

OpenCV具有完全符合您要求的绘图功能。

对于Java,请参阅:

对于C ++,请参阅:

相关问题