8000 GitHub - baiIey/bike-canvas: Use serialization to capture Canvas drawings as a string and store them using Firebase's real-time database
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

baiIey/bike-canvas

Repository files navigation

Cycle()

This experiment explores how a population of a thousand unique self-selected individuals, equipped with a given set of tools, responded when prompted to recall and reproduce a familiar object.

  • Prompt : For this task, we ask that you draw a bicycle.
  • Audience : Amazon's Mechanical Turk
  • Average time per assignment : 131 seconds
  • Reward per assignment : $0.15
  • Countries of origin : 30

This project and its paper describe the psychological phenomenon of overlooking cotidian objects. It explores the consequences of such oversight and considers the outcomes of an experiment in which we asked 1,000 randomly self-selected people to draw a bicycle without looking at a picture.

Similar Works

References

Development

Mechanical Turk

We requested 1000 submissions from Amazon's Mechanical Turk, asking only that workers "Draw a bike", and paid them $0.15 each to do so.

Firebase Anonymous Authentication

We control access to our Firebase database by authenticating anonymously for each of our Mechanical Turks. The authentication listener creates a unique ID for each user, which we associate with our submissions when doing initial QA.

$("#startBtn").click(function(){
			$("#intro").hide();
			$("#draw").show();
			console.log("startBtn did press")
			startRecording();
			console.log("recording...")
			firebase.auth().signInAnonymously();
	    console.log('sign in anonymously')

			// auth listener
			firebase.auth().onAuthStateChanged(firebaseUser => {
				console.log(firebaseUser);
			});
		});

Serialization

This block saves the content on canvas as a string and passes it to Firebase.

$("#serializeBtn").click(function() {
  var serResult = serializeDrawing(drawing);

  console.log("serializeBtn/Submit did press");
  $("#draw").hide();
  $("#exit").show();
  if (serResult != null)
  {
    $("#serDataTxt").val(serResult);
    // showSerializerDiv();
    console.log("serialization worked");
    console.log(serResult);
    firebase.database().ref('UIDs/').push({
      drawing: serResult
    });
  } else
  {
    alert("Error serializing data");
    console.log("serialization error");
  }
});

Fetch Drawings

This loops through drawings in order of submission with Firebase's forEach() method. The callback provided to will be called synchronously with a DataSnapshot for each child

firebase.database().ref("UIDs").once("value",function() {});
var query = firebase.database().ref("UIDs").orderByKey();

query.once("value")
  .then(function(snapshot) {
    var a = snapshot.numChildren();
    console.log(a);
    snapshot.forEach(function(childSnapshot) {
      // key will be "ada" the first time and "alan" the second time
      var key = childSnapshot.key;
      // childData will be the actual contents of the child
      var serResult = snapshot.child(key).child("drawing").val();

      // console.log(drawing);
      var eName = childSnapshot.val().resultname;
      document.getElementById("draw").innerHTML += '<canvas class="canvas">'+serResult+'</canvas>';

      drawing = new RecordableDrawing("canvas");
  });
});

About

Use serialization to capture Canvas drawings as a string and store them using Firebase's real-time database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0