Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

ANDROID MODE 4+ support to Keitai camera, or other ways to access camera?

$
0
0

Hey, how is it going?

Im working on an app that needs to get videos from the mobile`s camera in real time. Before downloading version 4+ of android mode it was working fine, but I had to get 4+ because its gonna be a virtual reality (cardboard) app.

I was using android 7.0 (API 24) and it was working, i could access the camera using the CameraGettingStarted from ketai, but the recommended android SDK for android mode 4+ is the 6.0 (API 23) and since ive installed it the example doesnt work, it crashes when I click to start the camera. One thing ive noticed is that it doesnt crash until i click, so i tried putting the line:

cam = new KetaiCamera(this, width, height, 24);

inside setup, and then it crashes when it starts, suggesting that this is the part when something wrong happens.

Anyone tried accessing camera using the same android mode and sdk versions? Any suggestions?

One other solution would be getting the images from the camera without the library, but I have no idea how to do that.

Basically i need to get the camera in real time to do some image processing to the frames and display them. Here`s an example code, what i get is: gray screen with "Waiting for camera....touch to activate" working with cardboard features, when i click the screen it crashes, if i put that line on setup it crashes when it starts. Its basically the getting started example from ketai with cardboard added

import processing.cardboard.*;
import ketai.camera.*;

KetaiCamera cam;

void setup() {
  fullScreen(PCardboard.STEREO);
  orientation(LANDSCAPE);
  imageMode(CENTER);
  textSize(45);

  //cam = new KetaiCamera(this, 640, 480, 24); //this is the line that crashes when app starts if not commented
}

void draw() {
  background(0);
  if (cam != null && cam.isStarted())
    image(cam, width/2, height/2, width, height);
  else {
    background(128);
    text("Waiting for camera....touch to activate", 100, height/2);
  }
}

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 keyPressed() {
  if (cam == null)
    return;

  if (key == CODED) {
    if (keyCode == MENU) {
      if (cam.isFlashEnabled())
        cam.disableFlash();
      else
        cam.enableFlash();
    }
  }
}

any tips or ideas welcome! thanks in advance!


Viewing all articles
Browse latest Browse all 941

Trending Articles