feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
75
3rdparty/opencv-4.5.4/samples/java/tutorial_code/video/meanshift/CamshiftDemo.java
vendored
Normal file
75
3rdparty/opencv-4.5.4/samples/java/tutorial_code/video/meanshift/CamshiftDemo.java
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
import java.util.Arrays;
|
||||
import org.opencv.core.*;
|
||||
import org.opencv.highgui.HighGui;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.opencv.video.Video;
|
||||
import org.opencv.videoio.VideoCapture;
|
||||
|
||||
|
||||
class Camshift {
|
||||
public void run(String[] args) {
|
||||
String filename = args[0];
|
||||
VideoCapture capture = new VideoCapture(filename);
|
||||
if (!capture.isOpened()) {
|
||||
System.out.println("Unable to open file!");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Mat frame = new Mat(), hsv_roi = new Mat(), mask = new Mat(), roi;
|
||||
|
||||
// take the first frame of the video
|
||||
capture.read(frame);
|
||||
|
||||
//setup initial location of window
|
||||
Rect track_window = new Rect(300, 200, 100, 50);
|
||||
|
||||
// set up the ROI for tracking
|
||||
roi = new Mat(frame, track_window);
|
||||
Imgproc.cvtColor(roi, hsv_roi, Imgproc.COLOR_BGR2HSV);
|
||||
Core.inRange(hsv_roi, new Scalar(0, 60, 32), new Scalar(180, 255, 255), mask);
|
||||
|
||||
MatOfFloat range = new MatOfFloat(0, 256);
|
||||
Mat roi_hist = new Mat();
|
||||
MatOfInt histSize = new MatOfInt(180);
|
||||
MatOfInt channels = new MatOfInt(0);
|
||||
Imgproc.calcHist(Arrays.asList(hsv_roi), channels, mask, roi_hist, histSize, range);
|
||||
Core.normalize(roi_hist, roi_hist, 0, 255, Core.NORM_MINMAX);
|
||||
|
||||
// Setup the termination criteria, either 10 iteration or move by atleast 1 pt
|
||||
TermCriteria term_crit = new TermCriteria(TermCriteria.EPS | TermCriteria.COUNT, 10, 1);
|
||||
|
||||
while (true) {
|
||||
Mat hsv = new Mat() , dst = new Mat();
|
||||
capture.read(frame);
|
||||
if (frame.empty()) {
|
||||
break;
|
||||
}
|
||||
Imgproc.cvtColor(frame, hsv, Imgproc.COLOR_BGR2HSV);
|
||||
Imgproc.calcBackProject(Arrays.asList(hsv), channels, roi_hist, dst, range, 1);
|
||||
|
||||
// apply camshift to get the new location
|
||||
RotatedRect rot_rect = Video.CamShift(dst, track_window, term_crit);
|
||||
|
||||
// Draw it on image
|
||||
Point[] points = new Point[4];
|
||||
rot_rect.points(points);
|
||||
for (int i = 0; i < 4 ;i++) {
|
||||
Imgproc.line(frame, points[i], points[(i+1)%4], new Scalar(255, 0, 0),2);
|
||||
}
|
||||
|
||||
HighGui.imshow("img2", frame);
|
||||
int keyboard = HighGui.waitKey(30);
|
||||
if (keyboard == 'q'|| keyboard == 27) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public class CamshiftDemo {
|
||||
public static void main(String[] args) {
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
new Camshift().run(args);
|
||||
}
|
||||
}
|
70
3rdparty/opencv-4.5.4/samples/java/tutorial_code/video/meanshift/MeanshiftDemo.java
vendored
Normal file
70
3rdparty/opencv-4.5.4/samples/java/tutorial_code/video/meanshift/MeanshiftDemo.java
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
import java.util.Arrays;
|
||||
import org.opencv.core.*;
|
||||
import org.opencv.highgui.HighGui;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.opencv.video.Video;
|
||||
import org.opencv.videoio.VideoCapture;
|
||||
|
||||
|
||||
class Meanshift {
|
||||
public void run(String[] args) {
|
||||
String filename = args[0];
|
||||
VideoCapture capture = new VideoCapture(filename);
|
||||
if (!capture.isOpened()) {
|
||||
System.out.println("Unable to open file!");
|
||||
System.exit(-1);
|
||||
}
|
||||
Mat frame = new Mat(), hsv_roi = new Mat(), mask = new Mat(), roi;
|
||||
|
||||
// take the first frame of the video
|
||||
capture.read(frame);
|
||||
|
||||
//setup initial location of window
|
||||
Rect track_window = new Rect(300, 200, 100, 50);
|
||||
|
||||
// setup initial location of window
|
||||
roi = new Mat(frame, track_window);
|
||||
Imgproc.cvtColor(roi, hsv_roi, Imgproc.COLOR_BGR2HSV);
|
||||
Core.inRange(hsv_roi, new Scalar(0, 60, 32), new Scalar(180, 255, 255), mask);
|
||||
|
||||
MatOfFloat range = new MatOfFloat(0, 256);
|
||||
Mat roi_hist = new Mat();
|
||||
MatOfInt histSize = new MatOfInt(180);
|
||||
MatOfInt channels = new MatOfInt(0);
|
||||
Imgproc.calcHist(Arrays.asList(hsv_roi), channels, mask, roi_hist, histSize, range);
|
||||
Core.normalize(roi_hist, roi_hist, 0, 255, Core.NORM_MINMAX);
|
||||
|
||||
// Setup the termination criteria, either 10 iteration or move by atleast 1 pt
|
||||
TermCriteria term_crit = new TermCriteria(TermCriteria.EPS | TermCriteria.COUNT, 10, 1);
|
||||
|
||||
while (true) {
|
||||
Mat hsv = new Mat() , dst = new Mat();
|
||||
capture.read(frame);
|
||||
if (frame.empty()) {
|
||||
break;
|
||||
}
|
||||
Imgproc.cvtColor(frame, hsv, Imgproc.COLOR_BGR2HSV);
|
||||
Imgproc.calcBackProject(Arrays.asList(hsv), channels, roi_hist, dst, range, 1);
|
||||
|
||||
// apply meanshift to get the new location
|
||||
Video.meanShift(dst, track_window, term_crit);
|
||||
|
||||
// Draw it on image
|
||||
Imgproc.rectangle(frame, track_window, new Scalar(255, 0, 0), 2);
|
||||
HighGui.imshow("img2", frame);
|
||||
|
||||
int keyboard = HighGui.waitKey(30);
|
||||
if (keyboard == 'q' || keyboard == 27) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public class MeanshiftDemo {
|
||||
public static void main(String[] args) {
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
new Meanshift().run(args);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user