Skip to content

Commit 6f66d71

Browse files
authored
Merge branch 'opencv:master' into loop_closure_detecion
2 parents 1446a10 + 907efb9 commit 6f66d71

File tree

31 files changed

+332
-49
lines changed

31 files changed

+332
-49
lines changed

modules/alphamat/src/cm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ void lle(my_vector_of_vectors_t& indm, my_vector_of_vectors_t& samples, float ep
9090
Mat ptDotN(20, 1, DataType<float>::type), imd(20, 1, DataType<float>::type);
9191
Mat Cones(20, 1, DataType<float>::type), Cinv(20, 1, DataType<float>::type);
9292
float alpha, beta, lagrangeMult;
93-
Cones = 1;
93+
Cones.setTo(cv::Scalar::all(1));
9494

95-
C = 0;
95+
C.setTo(cv::Scalar::all(0));
9696
rhs = 1;
9797

9898
int i, ind = 0;

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,18 @@ class CV_EXPORTS_W Board {
281281
*
282282
*/
283283
CV_WRAP static Ptr<Board> create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &dictionary, InputArray ids);
284+
285+
/**
286+
* @brief Set ids vector
287+
*
288+
* @param ids vector of the identifiers of the markers in the board (should be the same size
289+
* as objPoints)
290+
*
291+
* Recommended way to set ids vector, which will fail if the size of ids does not match size
292+
* of objPoints.
293+
*/
294+
CV_WRAP void setIds(InputArray ids);
295+
284296
/// array of object points of all the marker corners in the board
285297
/// each marker include its 4 corners in CCW order. For M markers, the size is Mx4.
286298
CV_PROP std::vector< std::vector< Point3f > > objPoints;
@@ -290,7 +302,7 @@ class CV_EXPORTS_W Board {
290302

291303
/// vector of the identifiers of the markers in the board (same size than objPoints)
292304
/// The identifiers refers to the board dictionary
293-
CV_PROP std::vector< int > ids;
305+
CV_PROP_RW std::vector< int > ids;
294306
};
295307

296308

modules/aruco/misc/objc/gen_dict.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
"*" : [ "\"aruco.hpp\"" ],
44
"CharucoBoard" : [ "\"aruco/charuco.hpp\"" ],
55
"Dictionary" : [ "\"aruco/dictionary.hpp\"" ]
6+
},
7+
"func_arg_fix" : {
8+
"Board" : {
9+
"(void)setIds:(Mat*)ids" : { "setIds" : {"name" : "setIdsMat"} }
10+
}
611
}
712
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
3+
# Python 2/3 compatibility
4+
from __future__ import print_function
5+
6+
import os, numpy as np
7+
8+
import cv2 as cv
9+
10+
from tests_common import NewOpenCVTests
11+
12+
class aruco_test(NewOpenCVTests):
13+
14+
def test_idsAccessibility(self):
15+
16+
ids = np.array([[elem] for elem in range(17)])
17+
rev_ids = np.array(list(reversed(ids)))
18+
19+
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_5X5_250)
20+
board = cv.aruco.CharucoBoard_create(7, 5, 1, 0.5, aruco_dict)
21+
22+
self.assertTrue(np.equal(board.ids, ids).all())
23+
24+
board.ids = rev_ids
25+
self.assertTrue(np.equal(board.ids, rev_ids).all())
26+
27+
board.setIds(ids)
28+
self.assertTrue(np.equal(board.ids, ids).all())
29+
30+
with self.assertRaises(cv.error):
31+
board.setIds(np.array([0]))
32+
33+
if __name__ == '__main__':
34+
NewOpenCVTests.bootstrap()

modules/aruco/src/aruco.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,13 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
14971497
return res;
14981498
}
14991499

1500+
/**
1501+
*/
1502+
void Board::setIds(InputArray ids_) {
1503+
CV_Assert(objPoints.size() == ids_.total());
1504+
ids_.copyTo(this->ids);
1505+
}
1506+
15001507
/**
15011508
*/
15021509
Ptr<GridBoard> GridBoard::create(int markersX, int markersY, float markerLength, float markerSeparation,

modules/bgsegm/src/synthetic_seq.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void SyntheticSequenceGenerator::getNextFrame(OutputArray _frame, OutputArray _g
206206

207207
_gtMask.create(sz, CV_8U);
208208
Mat gtMask = _gtMask.getMat();
209-
gtMask = 0;
209+
gtMask.setTo(cv::Scalar::all(0));
210210
gtMask(Rect(Point2i(pos), objSz)) = 255;
211211

212212
pos += dir * objspeed;

modules/cudacodec/include/opencv2/cudacodec.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ struct FormatInfo
282282
{
283283
Codec codec;
284284
ChromaFormat chromaFormat;
285-
int nBitDepthMinus8;
286-
int width;
287-
int height;
285+
int nBitDepthMinus8 = -1;
286+
int width = 0;//!< Width of the decoded frame returned by nextFrame(frame)
287+
int height = 0;//!< Height of the decoded frame returned by nextFrame(frame)
288+
Rect displayArea;//!< ROI inside the decoded frame returned by nextFrame(frame), containing the useable video frame.
289+
bool valid = false;
288290
};
289291

290292
/** @brief Video reader interface.
@@ -329,6 +331,10 @@ class CV_EXPORTS_W RawVideoSource
329331
/** @brief Returns information about video file format.
330332
*/
331333
virtual FormatInfo format() const = 0;
334+
335+
/** @brief Updates the coded width and height inside format.
336+
*/
337+
virtual void updateFormat(const int codedWidth, const int codedHeight) = 0;
332338
};
333339

334340
/** @brief Creates video reader.

modules/cudacodec/src/cuvid_video_source.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource(const String& fname)
7474
format_.nBitDepthMinus8 = vidfmt.bit_depth_luma_minus8;
7575
format_.width = vidfmt.coded_width;
7676
format_.height = vidfmt.coded_height;
77+
format_.displayArea = Rect(Point(vidfmt.display_area.left, vidfmt.display_area.top), Point(vidfmt.display_area.right, vidfmt.display_area.bottom));
78+
format_.valid = true;
7779
}
7880

7981
cv::cudacodec::detail::CuvidVideoSource::~CuvidVideoSource()
@@ -86,6 +88,13 @@ FormatInfo cv::cudacodec::detail::CuvidVideoSource::format() const
8688
return format_;
8789
}
8890

91+
void cv::cudacodec::detail::CuvidVideoSource::updateFormat(const int codedWidth, const int codedHeight)
92+
{
93+
format_.width = codedWidth;
94+
format_.height = codedHeight;
95+
format_.valid = true;
96+
}
97+
8998
void cv::cudacodec::detail::CuvidVideoSource::start()
9099
{
91100
cuSafeCall( cuvidSetVideoSourceState(videoSource_, cudaVideoState_Started) );

modules/cudacodec/src/cuvid_video_source.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CuvidVideoSource : public VideoSource
5555
~CuvidVideoSource();
5656

5757
FormatInfo format() const CV_OVERRIDE;
58+
void updateFormat(const int codedWidth, const int codedHeight);
5859
void start() CV_OVERRIDE;
5960
void stop() CV_OVERRIDE;
6061
bool isStarted() const CV_OVERRIDE;

modules/cudacodec/src/ffmpeg_video_source.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname)
131131
format_.codec = FourccToCodec(codec);
132132
format_.height = cap.get(CAP_PROP_FRAME_HEIGHT);
133133
format_.width = cap.get(CAP_PROP_FRAME_WIDTH);
134+
format_.displayArea = Rect(0, 0, format_.width, format_.height);
135+
format_.valid = false;
134136
FourccToChromaFormat(pixelFormat, format_.chromaFormat, format_.nBitDepthMinus8);
135137
}
136138

@@ -145,6 +147,13 @@ FormatInfo cv::cudacodec::detail::FFmpegVideoSource::format() const
145147
return format_;
146148
}
147149

150+
void cv::cudacodec::detail::FFmpegVideoSource::updateFormat(const int codedWidth, const int codedHeight)
151+
{
152+
format_.width = codedWidth;
153+
format_.height = codedHeight;
154+
format_.valid = true;
155+
}
156+
148157
bool cv::cudacodec::detail::FFmpegVideoSource::getNextPacket(unsigned char** data, size_t* size)
149158
{
150159
cap >> rawFrame;

0 commit comments

Comments
 (0)