feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
96
3rdparty/opencv-4.5.4/samples/java/tutorial_code/ImgTrans/HoughLine/HoughLines.java
vendored
Normal file
96
3rdparty/opencv-4.5.4/samples/java/tutorial_code/ImgTrans/HoughLine/HoughLines.java
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @file HoughLines.java
|
||||
* @brief This program demonstrates line finding with the Hough transform
|
||||
*/
|
||||
|
||||
import org.opencv.core.*;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.highgui.HighGui;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
class HoughLinesRun {
|
||||
|
||||
public void run(String[] args) {
|
||||
// Declare the output variables
|
||||
Mat dst = new Mat(), cdst = new Mat(), cdstP;
|
||||
|
||||
//! [load]
|
||||
String default_file = "../../../../data/sudoku.png";
|
||||
String filename = ((args.length > 0) ? args[0] : default_file);
|
||||
|
||||
// Load an image
|
||||
Mat src = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE);
|
||||
|
||||
// Check if image is loaded fine
|
||||
if( src.empty() ) {
|
||||
System.out.println("Error opening image!");
|
||||
System.out.println("Program Arguments: [image_name -- default "
|
||||
+ default_file +"] \n");
|
||||
System.exit(-1);
|
||||
}
|
||||
//! [load]
|
||||
|
||||
//! [edge_detection]
|
||||
// Edge detection
|
||||
Imgproc.Canny(src, dst, 50, 200, 3, false);
|
||||
//! [edge_detection]
|
||||
|
||||
// Copy edges to the images that will display the results in BGR
|
||||
Imgproc.cvtColor(dst, cdst, Imgproc.COLOR_GRAY2BGR);
|
||||
cdstP = cdst.clone();
|
||||
|
||||
//! [hough_lines]
|
||||
// Standard Hough Line Transform
|
||||
Mat lines = new Mat(); // will hold the results of the detection
|
||||
Imgproc.HoughLines(dst, lines, 1, Math.PI/180, 150); // runs the actual detection
|
||||
//! [hough_lines]
|
||||
//! [draw_lines]
|
||||
// Draw the lines
|
||||
for (int x = 0; x < lines.rows(); x++) {
|
||||
double rho = lines.get(x, 0)[0],
|
||||
theta = lines.get(x, 0)[1];
|
||||
|
||||
double a = Math.cos(theta), b = Math.sin(theta);
|
||||
double x0 = a*rho, y0 = b*rho;
|
||||
Point pt1 = new Point(Math.round(x0 + 1000*(-b)), Math.round(y0 + 1000*(a)));
|
||||
Point pt2 = new Point(Math.round(x0 - 1000*(-b)), Math.round(y0 - 1000*(a)));
|
||||
Imgproc.line(cdst, pt1, pt2, new Scalar(0, 0, 255), 3, Imgproc.LINE_AA, 0);
|
||||
}
|
||||
//! [draw_lines]
|
||||
|
||||
//! [hough_lines_p]
|
||||
// Probabilistic Line Transform
|
||||
Mat linesP = new Mat(); // will hold the results of the detection
|
||||
Imgproc.HoughLinesP(dst, linesP, 1, Math.PI/180, 50, 50, 10); // runs the actual detection
|
||||
//! [hough_lines_p]
|
||||
//! [draw_lines_p]
|
||||
// Draw the lines
|
||||
for (int x = 0; x < linesP.rows(); x++) {
|
||||
double[] l = linesP.get(x, 0);
|
||||
Imgproc.line(cdstP, new Point(l[0], l[1]), new Point(l[2], l[3]), new Scalar(0, 0, 255), 3, Imgproc.LINE_AA, 0);
|
||||
}
|
||||
//! [draw_lines_p]
|
||||
|
||||
//! [imshow]
|
||||
// Show results
|
||||
HighGui.imshow("Source", src);
|
||||
HighGui.imshow("Detected Lines (in red) - Standard Hough Line Transform", cdst);
|
||||
HighGui.imshow("Detected Lines (in red) - Probabilistic Line Transform", cdstP);
|
||||
//! [imshow]
|
||||
|
||||
//! [exit]
|
||||
// Wait and Exit
|
||||
HighGui.waitKey();
|
||||
System.exit(0);
|
||||
//! [exit]
|
||||
}
|
||||
}
|
||||
|
||||
public class HoughLines {
|
||||
public static void main(String[] args) {
|
||||
// Load the native library.
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
new HoughLinesRun().run(args);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user