Skip to content

Instantly share code, notes, and snippets.

@sellmair
Last active May 10, 2018 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sellmair/a0286b74b3516da1712905f4d9c7e99d to your computer and use it in GitHub Desktop.
Save sellmair/a0286b74b3516da1712905f4d9c7e99d to your computer and use it in GitHub Desktop.
Phantom Types in Kotlin: Modelling a Pipeline. Request Inhertiance
/**
* This is our base request.
* It contains the image taken by the camera
* The timestamp when it was taken (because it obviously matters)
* And some additional settings for the measure algorithm
*/
open class Request(
val image: Image,
val timestamp: Timestamp,
val settings: MeasureSettings)
/**
* This is the special request necessary for detecting basic shapes
* in an image.
*
* This also needs preparedImages, because the vision framework
* we are using cannot work with the Image type taken from the camera
* directly.
*
* We also want to provide a scaled version of the prepared image
* To prevent every detector to scale the image down by itself (which can be expensive)
*/
class ShapeDetectionRequest(
val preparedImage: Mat,
val preparedScaledImage: Mat,
override val image: Image,
override val timestamp: Timestamp,
override val MeasureSettings): Request
/**
* This is the special request necessary for detecting basic features
* like arms, shoes, faces, etc in an imagge.
*/
class FeatureDetectionRequest(
val shapes: List<Shape>,
val preparedImage: Mat,
val preparedScaledImage: Mat,
override val image: Image,
override val timestamp: Timestamp,
override val MeasureSettings): Request
/* AND SO ON AND ON AND ON */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment