RPTools.net
http://forums.rptools.net/

Use Real Dice Rolls?
http://forums.rptools.net/viewtopic.php?f=5&t=27177
Page 2 of 2

Author:  Full Bleed [ Mon Apr 24, 2017 10:04 am ]
Post subject:  Re: Use Real Dice Rolls?

Btw, here is some source code for java based facial recognition software: http://www.advancedsourcecode.com/javaface.asp

After watching the linked youtube video, I think it would be pretty easy to try and use this for "dice" recognition. I don't know what recognition methods it's using (faces are, after all, different than dice)... but it would be a good place to start. Start with a D6 and take baseline top-down pictures of the dice to set the "Select the Image to be Recognized" images. Then take a bunch of random shots of D6 dice from above and with varying orientations and angles... and see how well the program handles the recognition.

If it works really well... you might have something to build on.

Author:  jfrazierjr [ Mon Apr 24, 2017 11:22 am ]
Post subject:  Re: Use Real Dice Rolls?

pirklbauer31 wrote:
That's why I asked if it was possible to combine using real dice with RPTools



If you build a java class which can "read" dice, in whatever way you decided to build such an application, then we can easily help you plug in the actual results for SIMPLE dice rolls. Regardless of how you actual "read" the dice rolls:

  • bluetooth dice, which I would assume would be very expensive
  • camera software that turns the dice into a number
  • some form of magic I am unaware of

THEN once that's done, we can deal with how maptool is "notified" that there is dice rolled to deal with.

If for some reason, you don't want to do java, well, then thing get a bit more complicated, but not overely so. In this case, I would have MapTool configured with a webservice. This is where things get tricky since you really HAVE to decide ahead of time something. Will you tell MapTool someone is about to rolls some dice, then read the results from the external application, and plug into MapTool

OR

Will you roll the dice first manually and THEN tell Dicetool the result/go get the result.

Either way is acceptable.

Honestly, the more I think about it, the more I think that MapTool hosting a webservice call and/or(ie for either way) a web service client would be best and then it could be fairly extensible to other applications with a correct API without the external application needing to know anything about MapTool's internals.

One issue with your thought process would be: what happens with various game mechanics? Example:

Shadowrun's variable dice pool. Does it default to count successes, does it default to just summing all the dice, what?

D&D 5e's Advantage/Disadvantge. In that system you have modifiers to either roll d20 twice and take the higher or d20 twice and take the lower depending upon the situation. Would you be required to roll BOTH at the same time so MapTool could somehow know to apply only one of the two possible results(this could be accomplished with quickly and easily with a variable to say if high/low is used), but what happens if the person only rolls a SINGLE d20.

The thing is, the simple cases really are simple. But as with game systems, thinks break down from simple once you have to start dealing with the changes from one game system to another.

Author:  jfrazierjr [ Mon Apr 24, 2017 11:24 am ]
Post subject:  Re: Use Real Dice Rolls?

Full Bleed wrote:
Btw, here is some source code for java based facial recognition software: http://www.advancedsourcecode.com/javaface.asp

After watching the linked youtube video, I think it would be pretty easy to try and use this for "dice" recognition. I don't know what recognition methods it's using (faces are, after all, different than dice)... but it would be a good place to start. Start with a D6 and take baseline top-down pictures of the dice to set the "Select the Image to be Recognized" images. Then take a bunch of random shots of D6 dice from above and with varying orientations and angles... and see how well the program handles the recognition.

If it works really well... you might have something to build on.


And if this was supposed to be more than a project test, in order to make the reader software fairly good, you would have to also handle testing with various fonts on dice and 6 sided dice with pips vs actual numbers.

Author:  pirklbauer31 [ Mon Apr 24, 2017 11:43 am ]
Post subject:  Re: Use Real Dice Rolls?

jfrazierjr wrote:
pirklbauer31 wrote:
That's why I asked if it was possible to combine using real dice with RPTools



If you build a java class which can "read" dice, in whatever way you decided to build such an application, then we can easily help you plug in the actual results for SIMPLE dice rolls. Regardless of how you actual "read" the dice rolls:

  • bluetooth dice, which I would assume would be very expensive
  • camera software that turns the dice into a number
  • some form of magic I am unaware of

THEN once that's done, we can deal with how maptool is "notified" that there is dice rolled to deal with.

If for some reason, you don't want to do java, well, then thing get a bit more complicated, but not overely so. In this case, I would have MapTool configured with a webservice. This is where things get tricky since you really HAVE to decide ahead of time something. Will you tell MapTool someone is about to rolls some dice, then read the results from the external application, and plug into MapTool

OR

Will you roll the dice first manually and THEN tell Dicetool the result/go get the result.

Either way is acceptable.


  • I guess the image recognition part would be the best approach for getting the dice values.
  • Programming in Java is fine for me
  • I thought of first manually rolling the dice, then getting the result

The thing is, since I'm working on this semester-project alone and therefore I have limited time to do it, I was looking for already existing applications so I don't have to write that from scratch.
I'll probably focus on DnD since that's the game I play and know a bit about.
My Prof. also said, that a Proof of concept (The concept being: "Play DnD digitally, but still use real dice so you don't completely lose all physical aspect) as a result of
the project will be enough.
While searching for existing applications to play DnD i found Roll20 first(which turned out to not be the thing i was looking for) and RPTools.
Since RPTools seems to be OpenSource, I hoped to be able to use that for my project.

I hope what I wrote makes at least some kind of sense now.

Btw: Thanks for all the replies so far!

Author:  JamzTheMan [ Mon Apr 24, 2017 12:47 pm ]
Post subject:  Re: Use Real Dice Rolls?

Like jfrazierjr, there are several ways to tackle this. And unless you plan on writing the actual dice "recognition" code inside the MapTool project itself, it can come second. I would highly recommend the dice rolling to be a separate project and create an API in MapTool to access that "data".

It can start out as simple as your dice project logging it's results to a flat file and create a file watcher in MapTool to watch this file and pull in the results. Eventually moving to creating a macro command that "fetches" the results. Obviously you can't really initiate the dice process by rolling dice and pushing the results to MT as MT needs to know what these dice rolls are for. Unless you plan on creating a special "marker" to also be used. If it were me, and I was going to go the camera route, I may create some sort of custom flash card system with a QR code or something. The QR code would contain enough data to tell MapTool what you want to do with the dice rolls. Probably just a URI like maptool://macro?rollInit which calls the rollInit macro passing the dice results as arguments.

Creating your dice project outside of MapTool will give you more flexibility in choosing existing libraries to leverage. You wouldn't be locked into Java if you found, say, a better library to use written in C++.

So,
Step 1, flesh out the work flow (press MT macro, prompt user, roll dice? or roll dice, press MT macro? Roll dice & tell MT what to do? etc). Basically, how will the user tell MapTool how to use the dice he/she just rolled?
Step 2, Decide on technology (bluetooth, camera, some other sensor), start on a simple POC (proof of concept)
Step 3, Get your POC to display/log your results for a simple die
Step 4, Download MapTool from GitHub and get it to compile and run in your development environment
Step 5, Decide on API method or bake it into the MT project (if your POC is written in Java, you have options here)
Step 6, Flesh it out and profit!

So, unless the MapTool part is really the core of your project and the dice part is just black box, don't worry about it at this point. It can be solved several ways, none of them difficult. If you really want to nail down the MapTool part first, then you have to at least generate a program to simulate your dice results to send to MT.

Author:  pirklbauer31 [ Mon Apr 24, 2017 12:53 pm ]
Post subject:  Re: Use Real Dice Rolls?

JamzTheMan wrote:
Like jfrazierjr, there are several ways to tackle this. And unless you plan on writing the actual dice "recognition" code inside the MapTool project itself, it can come second. I would highly recommend the dice rolling to be a separate project and create an API in MapTool to access that "data".

It can start out as simple as your dice project logging it's results to a flat file and create a file watcher in MapTool to watch this file and pull in the results. Eventually moving to creating a macro command that "fetches" the results. Obviously you can't really initiate the dice process by rolling dice and pushing the results to MT as MT needs to know what these dice rolls are for. Unless you plan on creating a special "marker" to also be used. If it were me, and I was going to go the camera route, I may create some sort of custom flash card system with a QR code or something. The QR code would contain enough data to tell MapTool what you want to do with the dice rolls. Probably just a URI like maptool://macro?rollInit which calls the rollInit macro passing the dice results as arguments.

Creating your dice project outside of MapTool will give you more flexibility in choosing existing libraries to leverage. You wouldn't be locked into Java if you found, say, a better library to use written in C++.

So,
Step 1, flesh out the work flow (press MT macro, prompt user, roll dice? or roll dice, press MT macro? Roll dice & tell MT what to do? etc). Basically, how will the user tell MapTool how to use the dice he/she just rolled?
Step 2, Decide on technology (bluetooth, camera, some other sensor), start on a simple POC (proof of concept)
Step 3, Get your POC to display/log your results for a simple die
Step 4, Download MapTool from GitHub and get it to compile and run in your development environment
Step 5, Decide on API method or bake it into the MT project (if your POC is written in Java, you have options here)
Step 6, Flesh it out and profit!

So, unless the MapTool part is really the core of your project and the dice part is just black box, don't worry about it at this point. It can be solved several ways, none of them difficult. If you really want to nail down the MapTool part first, then you have to at least generate a program to simulate your dice results to send to MT.


According to this, it might actually work!
Thank you for your input and help so far :)

Author:  JamzTheMan [ Mon Apr 24, 2017 1:40 pm ]
Post subject:  Re: Use Real Dice Rolls?

Anything is possible with Time & Money. :D

Author:  wolph42 [ Mon Apr 24, 2017 5:37 pm ]
Post subject:  Re: Use Real Dice Rolls?

my $0.02: https://www.simplicity.be/article/recognizing-dices/

Author:  Full Bleed [ Mon Apr 24, 2017 10:13 pm ]
Post subject:  Re: Use Real Dice Rolls?

wolph42 wrote:

I just tried the facial recognition software I linked above... and it's a *fail* for dice when the orientation changes. Or, at least, using semi-translucent dice and color pictures as my test dice/pictures really fooled it by creating all kinds of random tones to match. ;)

I believe that the isolation/threshold techniques in your article would need to be used to remove various shadows, reflections, and extraneous data. But, even so, it will be far more complicated to remove some extraneous data from poly dice as you won't just be looking at pips.

This project will really end up being a poly dice/image recognition project.

Author:  wolph42 [ Tue Apr 25, 2017 4:45 am ]
Post subject:  Re: Use Real Dice Rolls?

I can imagine, there are so many variables to keep track of and indeed, the fact that the numeral system is used. Also the dice can rotate which means that classic OCR is also difficult e.g. try to recognize 6 and 9 rotated. Still for someone who wants to put time and effort in it, it can be a fun project. You can also decide to limit the scope to one specific set of dice, e.g. only black and white polys! e.g. this set is pretty common and most easy to OCR.

I mean if MT would at any time support ODR (optical dice recognition) but the function would be limited to one set of dice, I wouldn't hesitate to buy that set.

more link, more focused on java:
https://sourceforge.net/projects/javaocr/
http://tess4j.sourceforge.net/

previous one: https://www.simplicity.be/article/recognizing-dices/

Author:  Jagged [ Fri Sep 08, 2017 9:53 am ]
Post subject:  Re: Use Real Dice Rolls?

I think a way you could cope with the d4 would be to roll onto glass with the camera underneath.

Obviously you would need to read the results and convert them to appropriate value. Fortunately for us, dice tend to have fixed opposites.

Author:  taustinoc [ Fri Sep 08, 2017 10:10 am ]
Post subject:  Re: Use Real Dice Rolls?

Jagged wrote:
I think a way you could cope with the d4 would be to roll onto glass with the camera underneath.


Every d4 I've ever seen has three numbers on each face.

Author:  aliasmask [ Fri Sep 08, 2017 2:03 pm ]
Post subject:  Re: Use Real Dice Rolls?

taustinoc wrote:
Jagged wrote:
I think a way you could cope with the d4 would be to roll onto glass with the camera underneath.


Every d4 I've ever seen has three numbers on each face.


I guess technically it can be done. It would just be the number you don't see on the side facing down.

Author:  RPTroll [ Mon Sep 18, 2017 8:16 am ]
Post subject:  Re: Use Real Dice Rolls?

I'd also recommend going with a gaming system that uses all d6 to limit the scope.

Page 2 of 2 All times are UTC - 6 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/