1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenCVSharpのFindContoursAsArray()は破壊的である

Last updated at Posted at 2015-04-07

OpenCVの輪郭検出関数findContours()は破壊的である。

void findContours(const Mat& image, vector >& contours, vector& hierarchy, int mode, int method, Point offset=Point())
void findContours(const Mat& image, vector >& contours, int mode, int method, Point offset=Point())
2値画像中の輪郭を検出します.
(略)
注意: 元の image は,この関数によって書き換えられます.
http://opencv.jp/opencv-2svn/cpp/imgproc_structural_analysis_and_shape_descriptors.html#cv-findcontours

これはまぁ気をつければなんとか。

一方、これをwrapしたOpenCVSharpの関数はこういうシグネチャになっているが、これも破壊的なのである。

public Point[][] FindContoursAsArray(ContourRetrieval mode, ContourChain method, Point? offset = null)

元のものが壊されたくなければ、こうすればよい。

mat.Clone().FindContoursAsArray(ContourRetrieval.External, ContourChain.ApproxSimple)

気をつけるべし。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?