Skip to content
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

Expose dots which haven't been matched to a paper as markers #43

Merged
merged 2 commits into from
Apr 20, 2018

Conversation

paulsonnentag
Copy link
Contributor

I wanted to have markers which are tracked independently of the papers, similar to issue #42. I thought the fastest implementation would be to reuse the existing circle detection of the paper recognition. Any point which isn't part a corner shape is exposed as a marker on each paper object

const papers = await paper.get('papers');
const number = await paper.get('number');

// each paper has list of markers
papers[number].markers

I've build a little curling game with it:

img_20180414_204202
https://www.youtube.com/watch?v=0wXpnWLRP1Y

The only drawback I've noticed is that if a corner of a paper is partially covered the remaining dots are no longer part of a shape and will be recognized as markers. In my demo, I've dealt with this by using bigger circles for the markers and filter for the size in my paper program. The implementation isn't complete right now; I would also like to add the information which of the markers are on the paper and their relative position to the paper. I'm interested to hear your feedback.

@shaunlebron
Copy link
Contributor

I thought the fastest implementation would be to reuse the existing circle detection of the paper recognition.

Cool idea, when ready we can look at the square detection code here

I would also like to add the information which of the markers are on the paper and their relative position to the paper.

👍

Copy link
Owner

@janpaul123 janpaul123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Have some comments though. If you can't figure it out I'd be happy to take a look some time later. ☺️

// add markers to programs
programsToRender.forEach(programToRender => {
programToRender.markers = markers;
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing the markers as data on every paper seems a bit strange to me. Maybe allow access to them via paper.get('markers');? Or only expose the markers that are contained within a paper on the paper (similarly to how it works on DL)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe having both would be valuable?

  • myPaper.markers exposes markers on myPaper
  • paper.get('markers') exposes all markers that are not on any piece of paper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the most flexible way would be to receive all markers with paper.get('markers'). I thought about having both APIs like @sgwilym suggested, but then it get's complicated for some case for example If you want to get all markers. Instead we could add a paperId property and positionOnPaper property if the marker is on a paper.

Marker Object:

{ 
  position: {x, y},  // global position
  color: [r, g, b]
  colorName // "red", "green", "blue" or "black"

  // these properties will be null if the marker is not on a paper
  paperId,
  positionOnPaper: {x, y} // position converted to coordinate system of the paper
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea a lot!

.filter(({ matchedShape }) => !matchedShape)
.map(({ colorIndex, avgColor, pt, size }) => {
const { x, y } = projectPointToUnitSquare(pt, videoMat, config.knobPoints);
return { size, position: { x, y }, avgColor, colorIndex };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colorIndex might not be super meaningful to programs. How about omitting that and changing avgColor to simply color?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see how you used the colorIndex in the curling game and how that was convenient. Hm, I could get on board with that. Though might be nicer then to convert it to a colour name ("red", "green", etc)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with you, I'll change that.

Copy link
Owner

@janpaul123 janpaul123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, nice work! 💯

@janpaul123 janpaul123 merged commit 440971a into janpaul123:master Apr 20, 2018
@shaunlebron
Copy link
Contributor

Great start! We played with this, and drew circles over all the markers:

markers

Looks like the markers aren't attached to papers yet, so I'll remove that from the docs.

@shaunlebron shaunlebron mentioned this pull request Apr 24, 2018
@paulsonnentag
Copy link
Contributor Author

Yes, I've started working on that but haven't finished it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants