mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #22300 from komakai:fix-Mat-initWithSize
This commit is contained in:
commit
ebaf8cc06c
@ -98,7 +98,7 @@ static bool updateIdx(cv::Mat* mat, std::vector<int>& indices, size_t inc) {
|
|||||||
- (instancetype)initWithSize:(Size2i*)size type:(int)type {
|
- (instancetype)initWithSize:(Size2i*)size type:(int)type {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
_nativePtr = new cv::Mat(size.width, size.height, type);
|
_nativePtr = new cv::Mat(size.height, size.width, type);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ static bool updateIdx(cv::Mat* mat, std::vector<int>& indices, size_t inc) {
|
|||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
cv::Scalar scalerTemp(scalar.val[0].doubleValue, scalar.val[1].doubleValue, scalar.val[2].doubleValue, scalar.val[3].doubleValue);
|
cv::Scalar scalerTemp(scalar.val[0].doubleValue, scalar.val[1].doubleValue, scalar.val[2].doubleValue, scalar.val[3].doubleValue);
|
||||||
_nativePtr = new cv::Mat(size.width, size.height, type, scalerTemp);
|
_nativePtr = new cv::Mat(size.height, size.width, type, scalerTemp);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,12 @@ class MatTests: OpenCVTestCase {
|
|||||||
super.tearDown()
|
super.tearDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testInitWithSize() {
|
||||||
|
let size = Size(width: 7, height: 9)
|
||||||
|
let mat = Mat(size: size, type: CvType.CV_8U)
|
||||||
|
assertSizeEquals(size, mat.size())
|
||||||
|
}
|
||||||
|
|
||||||
func testAdjustROI() throws {
|
func testAdjustROI() throws {
|
||||||
let roi = gray0.submat(rowStart: 3, rowEnd: 5, colStart: 7, colEnd: 10)
|
let roi = gray0.submat(rowStart: 3, rowEnd: 5, colStart: 7, colEnd: 10)
|
||||||
let originalroi = roi.clone()
|
let originalroi = roi.clone()
|
||||||
|
Loading…
Reference in New Issue
Block a user