Skip to content

impl faster contours, fix leaks, update examples #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
{
"mir-algorithm": ">=3.15.3",
"mir-random": "2.2.19",
"bcaa": "0.0.8"
"bcaa": "0.0.8",
"dvector": "*"
},
"buildTypes": {
"unittest-release": {
Expand Down
3 changes: 2 additions & 1 deletion examples/maze/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ int main(string[] args)

imshow(imbin, "binary image");

auto cntrs = findContours(imbin); // find contours (binary boundaries)
auto cntrs_h = findContours(imbin); // find contours (binary boundaries)
auto cntrs = cntrs_h[0];
auto cimg = contours2image(cntrs, imbin.shape[0], imbin.shape[1]);

// fill contours
Expand Down
3 changes: 2 additions & 1 deletion examples/measure/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ int main(string[] args)

auto labels = bwlabel(imbin); // create label matrix

auto cntrs = findContours(imbin); // find contours (binary boundaries)
auto cntrs_h = findContours(imbin); // find contours (binary boundaries)
auto cntrs = cntrs_h[0];

foreach(contour; cntrs) // iterate over the regions
{
Expand Down
31 changes: 18 additions & 13 deletions source/dcv/core/utils.d
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,6 @@ private struct DRange

struct dlist(T)
{
import std.range : Take;

struct PayNode
{
BaseNode _base;
Expand Down Expand Up @@ -412,16 +410,15 @@ struct dlist(T)
{
static BaseNode* createNode(Stuff)(auto ref Stuff arg, BaseNode* prev = null, BaseNode* next = null)
{
auto pn = mmalloc!PayNode(PayNode.sizeof);
*pn = PayNode(BaseNode(prev, next), arg);

auto pn = mmalloc!PayNode(PayNode.sizeof);
*pn = PayNode(BaseNode(prev, next), arg);
return (pn).asBaseNode();
}

void initialize() nothrow
{
if (_root) return;
_root = (mmalloc!PayNode( PayNode.sizeof)).asBaseNode();
_root = (mmalloc!PayNode( PayNode.sizeof)).asBaseNode();
_root._next = _root._prev = _root;
}
ref inout(BaseNode*) _first() @property nothrow inout
Expand All @@ -445,7 +442,7 @@ struct dlist(T)
insertBack(stuff);
}

bool opEquals()(ref const DList rhs) const
bool opEquals()(ref const typeof(this) rhs) const
if (is(typeof(front == front)))
{
const lhs = this;
Expand Down Expand Up @@ -508,31 +505,39 @@ struct dlist(T)
}

void clear()
{
{
auto r = this[];

if (r.empty){
if(_root){
mfree(_root);
_root = null;
}
return;
}

BaseNode* last = null;
do
{
last = r._first;
r.popFront();
BaseNode.connect(_root, _first._next);
mfree(last);
} while ( !r.empty );

mfree(_root);
_root = null;


if(_root){
mfree(_root);
_root = null;
}

}

@property dlist dup()
@property typeof(this) dup()
{
return dlist(this[]);
typeof(this) dl;
dl.insertBack(this[]);
return dl;
}

Range opSlice()
Expand Down
Loading