ScratchData LogoScratchData
Back to Layzej's profile

Camera scanner - fixed (thx @Blue_Random!)

LALayzej•Created February 9, 2014
Camera scanner - fixed (thx @Blue_Random!)
433
376
9859 views
View on Scratch

Instructions

@Blue_Random has a much improved version here: https://scratch.mit.edu/projects/387204520/ The slider allows you to select the resolution. The greater the depth the clearer the picture - but also the more time it will take to scan. At the default setting it will look a lot like minecraft. You need a camera for this to work. It will provide a colour scan of whatever is seen through your camera. You will see black squares once it starts scanning.

Description

In Scratch you cannot query what colour a pixel is. Instead you can ask "Am I touching green/red/etc?" Unfortunately there are 16.7 million different colours in Scratch. This makes it tricky to scan a picture from the camera. You would have to query 16.7 million colours on each of the 172800 pixels. That program would never complete. But - if there are only 172800 pixels, then there can only be 172800 colours on the screen - and chances are there are much fewer. So I query all colours against the screen once. This leaves me with under 172800 colours to check against every pixel. Still too many. So I break the screen into quadrants and query just those colours against the quadrant. Next break the quadrant into four and query the smaller list of colours against each sub-quadrant. Etc Etc Etc until you arrive at the answer. The only other tricky part is keeping the clone count below 300 without hitting a deadlock.

Project Details

Project ID17713042
CreatedFebruary 9, 2014
Last ModifiedMay 5, 2020
SharedFebruary 10, 2014
Visibilityvisible
CommentsAllowed