Commit ee256af6 by 陈皓

init

parent d3813c70
......@@ -16,11 +16,7 @@ public class DemoUtil {
final static String URL = "localhost:8900/imgproc/v1/";
public static void main(String[] args) {
detection();
// String testImg = "C:/Users/11419/Desktop/Deskew/TestImages/4.png";
// String resImg = "C:/Users/11419/Desktop/Deskew/TestImages/res4.jpg";
// System.out.println(Convert.toInt(-6.25));
// ImgUtil.rotate(FileUtil.file(testImg), Convert.toInt(-6.25), FileUtil.file(resImg));
imageOptimization();
}
public static void detection() {
......@@ -44,8 +40,8 @@ public class DemoUtil {
}
public static void imageOptimization() {
String testImg = "C:/Users/11419/Desktop/Deskew/TestImages/F1550.jpg";
String resImg = "C:/Users/11419/Desktop/Deskew/TestImages/res.jpg";
String testImg = "C:/Users/11419/Desktop/Deskew/TestImages/6.png";
String resImg = "C:/Users/11419/Desktop/Deskew/TestImages/6res.png";
String url = URL + "imageOptimization";
OptimizationReq req = new OptimizationReq();
......
......@@ -10,10 +10,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.opencv.highgui.HighGui.imshow;
import static org.opencv.highgui.HighGui.waitKey;
public class Deskew {
public static void main(String[] args) {
System.load("C:/Users/11419/Desktop/lib/opencv_java460.dll");
System.load("D:/project/imgproc/lib/opencv_java460.dll");
Mat image = Imgcodecs.imread("C:/Users/11419/Desktop/Deskew/TestImages/4.png");
int angle = getDeskewAngle(image);
System.out.println(angle);
......@@ -133,18 +136,18 @@ public class Deskew {
int w = image.cols();
int h = image.rows();
// 定义参数
double scale = 1.0;
Point center = new Point((double) w / 2, (double) h / 2);
double scale = 1.0;
// 定义旋转矩阵
Mat rotationMatrix = Imgproc.getRotationMatrix2D(center, -angle, scale);
Mat rotationMatrix = Imgproc.getRotationMatrix2D(center, angle, scale);
// 旋转矩阵
Mat rotatedImage = new Mat();
// 设置填充颜色为白色
Scalar backgroundColor = new Scalar(255, 255, 255);
Mat rotatedImage = new Mat();
Imgproc.warpAffine(image, rotatedImage, rotationMatrix, new Size(w, h), Imgproc.INTER_LINEAR, Core.BORDER_CONSTANT, backgroundColor);
rotationMatrix.release();
return rotatedImage;
}
......
......@@ -24,6 +24,6 @@ imgconfig:
deskewpy: /opt/tianjin/lib/correct.py
#imgconfig:
# opencv: C:/Users/11419/Desktop/lib/opencv_java460.dll
# opencv: D:/project/imgproc/lib/opencv_java460.dll
# deskew: C:/Users/11419/Desktop/Deskew/Bin/deskew.exe
# deskewpy: C:/Users/11419/Desktop/lib/correct.py
# deskewpy: D:/project/imgproc/lib/correct.py
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment