createJourney
我正在尝试使用OpenCV 3.0在图像上制作水印,但是import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class Testingopencv
{
public static void main(String[] args)
{
System.loadLibrary("opencv_java300");
Mat src = Imgcodecs.imread("m.jpg");
Mat temp = new Mat(src.rows(),src.cols(), src.type());
Imgproc.putText(src, "Edited by me", new Point(src.rows()/2,src.cols()/2),
Core.FONT_ITALIC, 1.0 ,new Scalar(255));
Imgcodecs.imwrite("watermarked.jpg", src);
}
}
存在问题,我在互联网上搜索但没有解决方案。
错误消息是:
Imgproc类型中的方法putText(org.opencv.core.Mat,java.lang.String,org.opencv.core.Point,int,double,org.opencv.core.Scalar)不适用于参数(org.opencv.core.Mat,java.lang.String,java.awt.Point,int,double,org.opencv.core.Scalar)
参数应该正确如上面显示的消息。 我该如何解决这个问题?
答案 0 :(得分:2)
错误消息已显示问题:
方法putText(org.opencv.core.Mat,java.lang.String, org.opencv.core.Point ,int,double,org.opencv.core.Scalar)类型Imgproc不适用于参数(org.opencv.core.Mat,java.lang.String, java.awt.Point ,int,double,org.opencv.core.Scalar)
请务必将putText
作为org.opencv.core.Point
而不是java.awt.Point
传递给foreach ($item['option'] as $option) {
if ($option['availability']=0) { echo 'Not available'; } else { echo 'Available'; } }
。
答案 1 :(得分:1)
此代码正常运作。
// Draw a bounding box around each face.
for (Rect rect : faceDetections.toArray())
{
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 255));
// for crop face
rectCrop = new Rect(rect.x, rect.y, rect.width, rect.height);
Core.putText(image, "Edited by me", new Point(rect.x,rect.y),
Core.FONT_HERSHEY_PLAIN, 1.0 ,new Scalar(0,255,255));
}