This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
generated from obsproject/obs-plugintemplate
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from occ-ai/roy.crop_region
Crop region
- Loading branch information
Showing
6 changed files
with
147 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <opencv2/opencv.hpp> | ||
using namespace cv; | ||
|
||
void drawDashedLine(Mat &img, Point pt1, Point pt2, Scalar color, int thickness, int lineType, | ||
int dashLength) | ||
{ | ||
double lineLength = norm(pt1 - pt2); | ||
double angle = atan2(pt2.y - pt1.y, pt2.x - pt1.x); | ||
|
||
Point p1 = pt1; | ||
Point p2; | ||
bool draw = true; | ||
|
||
for (double d = 0; d < lineLength; d += dashLength) { | ||
if (draw) { | ||
p2.x = pt1.x + | ||
static_cast<int>(cos(angle) * std::min(d + dashLength, lineLength)); | ||
p2.y = pt1.y + | ||
static_cast<int>(sin(angle) * std::min(d + dashLength, lineLength)); | ||
line(img, p1, p2, color, thickness, lineType); | ||
} | ||
p1.x = pt1.x + static_cast<int>(cos(angle) * (d + dashLength)); | ||
p1.y = pt1.y + static_cast<int>(sin(angle) * (d + dashLength)); | ||
draw = !draw; | ||
} | ||
} | ||
|
||
void drawDashedRectangle(Mat &img, Rect rect, Scalar color, int thickness, int lineType, | ||
int dashLength) | ||
{ | ||
Point pt1(rect.x, rect.y); | ||
Point pt2(rect.x + rect.width, rect.y); | ||
Point pt3(rect.x + rect.width, rect.y + rect.height); | ||
Point pt4(rect.x, rect.y + rect.height); | ||
|
||
drawDashedLine(img, pt1, pt2, color, thickness, lineType, dashLength); | ||
drawDashedLine(img, pt2, pt3, color, thickness, lineType, dashLength); | ||
drawDashedLine(img, pt3, pt4, color, thickness, lineType, dashLength); | ||
drawDashedLine(img, pt4, pt1, color, thickness, lineType, dashLength); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef DETECT_FILTER_UTILS_H | ||
#define DETECT_FILTER_UTILS_H | ||
|
||
#include <opencv2/core/types.hpp> | ||
|
||
void drawDashedLine(cv::Mat &img, cv::Point pt1, cv::Point pt2, cv::Scalar color, int thickness = 1, | ||
int lineType = 8, int dashLength = 10); | ||
|
||
void drawDashedRectangle(cv::Mat &img, cv::Rect rect, cv::Scalar color, int thickness = 1, | ||
int lineType = 8, int dashLength = 10); | ||
|
||
#endif // DETECT_FILTER_UTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters