Skip to content

Commit bbc4df4

Browse files
committedJan 22, 2024
Add attribute with points to output
Fixes #39
1 parent 2a12008 commit bbc4df4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
 

‎DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: opencv
22
Type: Package
33
Title: Bindings to 'OpenCV' Computer Vision Library
4-
Version: 0.4.9000
4+
Version: 0.4.9001
55
Authors@R: c(
66
person("Jeroen", "Ooms", role = c("aut", "cre"), email = "jeroen@berkeley.edu",
77
comment = c(ORCID = "0000-0002-4035-0289")),

‎src/qrdetect.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ SEXP cvmat_qr_detect(XPtrMat ptr, bool return_image = false, bool use_wechat = t
3535
cv::Mat img = get_mat(ptr);
3636
if(!use_wechat)
3737
points = points.reshape(1, 4);
38-
for (int i = 0; i < points.size().height; i++) {
38+
int len = points.size().height;
39+
Rcpp::IntegerMatrix corners(len, 2);
40+
for (int i = 0; i < len; i++) {
3941
Point pt1 = cv::Point(points.row(i));
4042
Point pt2 = cv::Point(points.row((i + 1) % 4));
4143
line(img, pt1, pt2, Scalar(255, 0, 0), 3);
44+
corners[i] = pt1.x;
45+
corners[i+len] = pt1.y;
4246
}
4347
cv::putText(img, data,
4448
cv::Point(10, img.rows / 2), //left-middle position
@@ -47,6 +51,7 @@ SEXP cvmat_qr_detect(XPtrMat ptr, bool return_image = false, bool use_wechat = t
4751
CV_RGB(118, 185, 0), //font color
4852
2);
4953
ptr.attr("value") = Rcpp::CharacterVector::create(data);
54+
ptr.attr("points") = corners;
5055
return ptr;
5156
}
5257

0 commit comments

Comments
 (0)
Please sign in to comment.