Android image blob detection using blobscanner and ketai

edited November 2015 in Android Mode

I am trying to build an app that does blog detection using blobscanner and ketai libraries.

import ketai.camera.*;
import blobscanner.*;
KetaiCamera cam;
PImage img;
Detector bd;
int totalblobs=0;
void setup() {
  orientation(LANDSCAPE);
  imageMode(CENTER);
  textSize(45);
  bd = new Detector( this, 235 );
}

void draw() {

  if(cam != null && cam.isStarted()){

    image(cam, width/2, height/2, width, height);
    cam.savePhoto();
  }
  else
    {
      background(128);
      text("Waiting for camera....touch to activate", 100, height/2);
    }
    cam.filter(THRESHOLD);
    bd.imageFindBlobs(cam);
    totalblobs=bd.getBlobsNumber();
    if(totalblobs >=10 )
    {
      print("Photo captured");
    }
    delay(2000);

}

void onCameraPreviewEvent()
{
  cam.read();
}

// start/stop camera preview by tapping the screen
void mousePressed()
{
  //HACK: Instantiate camera once we are in the sketch itself
  if(cam == null)
      cam = new KetaiCamera(this, 640, 480, 24);

  if (cam.isStarted())
  {
    cam.stop();
  }
  else
    cam.start();
}

void exit()
{
  cam.stop();
}

The savePhoto() command doesn't seem to work and whenever I try to launch it, the app crashes. I want the app to take a photo and save it automatically when a certain amount of blobs are detected. I tried testing it on a Nexus 7 running 5.1.1. Any suggestions?

Answers

Sign In or Register to comment.