Abstract:

The perfect circle is a shiny app providing a user friendly interface to the algorithm described in the previous blog post Judging Freehand Circle Drawing Competitions. The app allows one to score freehand circles directly from the mobile by uploading photos of them them to a shiny server. An R package "perfectcircle" contains the scoring API as well as the shiny app.


Creative Commons License This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. The markdown+Rknitr source code of this blog is available under a GNU General Public License (GPL v3) license from github.

Introduction

The blog post Judging Freehand Circle Drawing Competitions contained an image analysis based procedure to automatically score the circularity of freehand drawn circles. What motivated the post was a curiosity on how one would rank different freehand drawn circles in a competition such as the one mentioned by Alexander Overwijk in his 2007 'Perfect Circle' video. A few weeks ago, I got an email in response to this post asking about the state of the scoring software, because there was an interest to hold a freehand circle drawing competition as part of a math teacher's conference. This motivated me to wrap the algorithm into a user friendly interface in order to increase the empty-set of potential users.

The Perfect Circle App

The circle segmentation functionality from the blog post was wrapped into an R package. In particular the function circularity takes an imager image (Barthelme 2019) and a data.frame with seedpoints and returns a circularity measure. This allows one to easily batch process the images of an entire competition in order to generate a leaderboard. Furthermore, a shiny app (Chang et al. 2017) is shipped as part of the package, which adds a user interface around this API of the package. Specifically, the app allows the user to upload their image and provide seed points either by uploading a .csv file or manually selecting the points in the image. The point selection was possible by using the ggplot-plotting functionality of the imager package together with the shiny::nearPoints function.

A general overview of the app is given by the following screencast:

The R source code of shiny app is available as part of the R package perfectcircle available from github under a GPLv3 license. A running version of the app can be reached at

http://michaelhoehle.eu/shiny/perfectcircle/

Note: Using the app from the above link can lead to "Disconnected from the server" errors when operating with high resolution images. Even though tracking memory consumption appears to reveal no problems, I suspect it to be an out-of-memory error of some sort - either by the R session run by the shiny server or an error in the imager package. However, reducing the image resolution using the Scale Factor so far always fixed the problem. Furthermore, I did not experience the problem when running the shiny app locally (Mac OS)

To better illustrate, how the shiny app can facilitate the scoring of circles on the fly with the camera of your mobile, I made an additional video tutorial about the adventures of a perfect circle:

Discussion

As always it was amazingly easy to use shiny to wrap a user interface around functionality written in R. I hope the app is useful to conduct your local freehand circle drawing competition! I would very much appreciate your feedback. If you want to share some of your best circles: bundles of image + seed point .csv files as pull requests to the round-1 folder on github are very welcomed!

An insight for me as non-millennial was the ease of the screen recording feature of Quicktime followed by uploading it to Youtube: With a few clicks the static-blackboard-fan thus created a first video blog entry! No less than amazing are IMHO the automatically generated subtitles on Youtube - a lot of machine learning has happened in speech recognition!

Literature

Barthelme, Simon. 2019. Imager: Image Processing Library Based on ’Cimg’. https://CRAN.R-project.org/package=imager.

Chang, Winston, Joe Cheng, JJ Allaire, Yihui Xie, and Jonathan McPherson. 2017. Shiny: Web Application Framework for R. https://CRAN.R-project.org/package=shiny.