Skip to content

I added a Pairwise Image Comparison Cell #22

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion modules/opencv/highgui/FPSDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace ecto_opencv
image.copyTo(output);
draw(output, freq);
out["image"] << output;
return 0;
return ecto::OK;
}
pt::ptime prev;
size_t count;
Expand Down
2 changes: 1 addition & 1 deletion modules/opencv/imgproc/Adder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace imgproc
{
*output_ = T();
*output_ = *a_ + *b_;
return 0;
return ecto::OK;
}
spore<T> a_, b_, output_;
};
Expand Down
2 changes: 1 addition & 1 deletion modules/opencv/imgproc/BitWiseNot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace imgproc
in["input"] >> input;
cv::bitwise_not(input, output);
out["out"] << output;
return 0;
return ecto::OK;
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion modules/opencv/imgproc/CartToPolar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace imgproc
*angle = cv::Mat();
*magnitude = cv::Mat();
cv::cartToPolar(*x, *y, *magnitude, *angle, true);
return 0;
return ecto::OK;
}
spore<cv::Mat> x, y, angle, magnitude;
};
Expand Down
68 changes: 68 additions & 0 deletions modules/opencv/imgproc/Pairwise.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <ecto/ecto.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core_c.h>
#include <iostream>
#include <vector>

using ecto::tendrils;
namespace imgproc
{
struct Pairwise
{

Pairwise() :
seq(0)
{}

static void declare_params(tendrils& p) {}

static void declare_io(const tendrils& params, tendrils& inputs, tendrils& outputs)
{
inputs.declare<cv::Mat>("image", "The n'th image");
outputs.declare<cv::Mat>("image1", "The (n-1)'th image unless n=0, then n'th image. ");
outputs.declare<cv::Mat>("image2", "The n'th image");
}

void configure(const tendrils& params, const tendrils& inputs, const tendrils& outputs)
{
input = inputs["image"];
output1 = outputs["image1"];
output2 = outputs["image2"];
}

int process(const tendrils& /*inputs*/, const tendrils& /*outputs*/)
{
// On the first processing call
if(seq == 0)
{
// Allocate an image like th eoe passed.
temp_storage = new cv::Mat(*input);
}

// Setup the return (output) values
*output1 = *input;
*output2 = *temp_storage;

// Don't need to copy on the first pass, already allocated from that
if(seq != 0)
{
// Otherwise, copy the current imput over the previous
input->copyTo(*temp_storage);
}

// Update the sequence number:
// TODO: present this number as a return?
seq += 1;
return ecto::OK;
}

size_t seq;
cv::Mat *temp_storage;
ecto::spore<cv::Mat> input, output1, output2;
};
}

// Not a stateless cell, so make sure there is only one instance at a time of this . . .
ECTO_THREAD_UNSAFE(imgproc::Pairwise);

ECTO_CELL(imgproc, imgproc::Pairwise, "Pairwise", "Cell for doing pairwise image comparison of sequential images.\n First return duplicates the first input. Later calls include the current image and the last that made its way throught the pipeline.");