3d scanner with Arduino and laser pointer

Its on @noel’s github

this ??

import android.app.Activity; 
import android.content.Intent; 
import android.provider.MediaStore; 

public static final int LAUNCH_CAM = 1; 

public void setup() { 
  orientation(LANDSCAPE); 
  Intent intent= new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA); 
  getActivity().startActivityForResult(intent, LAUNCH_CAM);
}

Android-java-code-utilities-widgets-for-Processing-for-Android/ Launch camera

my mistake i thought he posted a video lib on his repo, but it was the sound lib.

1 Like

@paulgoux how to use the code ?

import java.io.BufferedWriter;
import java.io.FileWriter;

String outFilename = "out.txt";

void setup(){
  // Write some text to the file
  for(int i=0; i<10; i++){
    appendTextToFile(outFilename, "Text " + i);
  } 
}

/**
 * Appends text to the end of a text file located in the data directory, 
 * creates the file if it does not exist.
 * Can be used for big files with lots of rows, 
 * existing lines will not be rewritten
 */
void appendTextToFile(String filename, String text){
  File f = new File(dataPath(filename));
  if(!f.exists()){
    createFile(f);
  }
  try {
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f, true)));
    out.println(text);
    out.close();
  }catch (IOException e){
      e.printStackTrace();
  }
}

/**
 * Creates a new file including all subfolders
 */
void createFile(File f){
  File parentDir = f.getParentFile();
  try{
    parentDir.mkdirs(); 
    f.createNewFile();
  }catch(Exception e){
    e.printStackTrace();
  }
} 
try {
  FileWriter output = new FileWriter("example.csv",true); //the true will append the new data
  output.println("a;b;c;this;that ");
  output.flush();
  output.close();
}
catch(IOException e) {
  println("It Broke :/");
  e.printStackTrace();
}

As for video @noel has a video sketch.

Hi @paulgoux this code how to save image from ketai camera ?

You just have to set the fileoutput.img variable.
Ketai produces an image for the cam stream, simply called cam, so set img to cam.

I did not understand

Theres a variable in the fileoutput class called img. Thats what it uses to save. If you want to save something else such as the ketai class variable cam which is a pgraphics object then you have to set img to cam.

I meant in the imageSaver class

All img set to cam ?

What do you mean all.

Just write

fileOutput f = new fileOutput();
f.img = cam

This will have to be done in draw or img wont have the most recent camera image.

I can not find this or maybe I am still not following with you

Sorry again this needs to be the image saver.

But please look at the code ive shared.

class imageSaver{
  Permission wstorage,rstorage;
  Activity act;
  PApplet p;
  int counter = -1,maxImageCount;
  boolean imageSaved,mdown;
  String folderName = "MyImageFolder",fileName,ext,absolutePath;
  String imageFile = "MyImage.jpg";

// see this variable is the one saved
  PImage img;
  File file,file2;
  
  imageSaver(PApplet applet){
    p = applet;
    wstorage = new Permission(p,"WRITE_EXTERNAL_STORAGE");
    act = p.getActivity();
    getExt(imageFile);
  };
  
  imageSaver(PApplet applet,String s1, String s2){
    folderName = s1;
    imageFi

alternatively using the following sketch

import android.os.Environment;
import android.Manifest; 
import android.content.pm.PackageManager; 
import android.os.Build; 
import android.os.Build.VERSION_CODES; 
import processing.core.PConstants;
import android.app.Activity; 

PImage img;
Activity activity; 
boolean image_saved;
boolean permissions_granted;

// Folowing file name is the folder you save your image file in.
// If it does not exist it will be created automatically
String folder_name = "MyImageFolder";

// Folowing string is the name of your image file
// Be sure to include extension.
String image_file = "MyImage.jpg";
Permission wstorage,rstorage;
void setup() {
  wstorage = new Permission(this,"WRITE_EXTERNAL_STORAGE");
  rstorage = new Permission(this,"READ_EXTERNAL_STORAGE");
  size(displayWidth, displayHeight);
  background(0, 0, 200); 
  rectMode(CENTER);
  rect(width/2, height/2, width, height/2);
  textAlign(CENTER);
  String str = "Click to save an image.";
  textSize(12);
  float twf = width/textWidth(str);
  textSize(8*twf);
  fill(0);
  text(str, width/2, height/2);
//rather than setting img here you set it in draw
  //img = get();
  //img.save(
};

void draw() {
//note you have to set it to whatever your ketaicamera instance is called + ".cam"
img = ketai.cam;
  if (image_saved) {
    background(0, 0, 200);
    fill(255);
    text("Image saved.", width/2, height/2);
  } 
};

void mousePressed() {
  saveMyImage(folder_name, image_file);
};

void saveMyImage(String sf, String tf) { 
  try { 
    String absolute_path = new String(Environment.getExternalStorageDirectory().getAbsolutePath()); 
    File file = new File(absolute_path+"/"+sf); 
    //println(file);
    if (!file.exists()) { 
      boolean success = true; 
      success = file.mkdirs();
      if(success){
        save(file+"/"+tf);
        image_saved = true;
        println("File saved successfully.");
        println("Path",absolute_path,"File",file);
      }
      else {
        println("no File");
        println("Path",absolute_path,"File",file);
      }
    } 
    
    
  } 
  catch (Exception e) { 
    //println("Error while saving file: " + e);
  }
};

@paulgoux thanks I am going to try your code at night

This is the first printed scan

1 Like

@paulgoux

hi

this ketai on android

import android.os.Environment;
import ketai.camera.*;
//import processing.video.*;
//Capture video ;
KetaiCamera video;
int Repetition; 
float pics_per_rev = 20; 

void setup() {
  size(640, 480);
  orientation(LANDSCAPE);
  video= new KetaiCamera(this, 600, 480, 30);
 // video= new Capture(this, 600, 480, 30);
 // video.setCameraID(0);                                        
  imageMode(CENTER);
 

  video.start();
}

void draw() {
 // image(video, width/2, height/2, width, height);
  drawUI();                                                   
onCameraPreviewEvent();
}

void drawUI() {                                            
}



void onCameraPreviewEvent() {
  video.read();

  image(video, 0, 0, width, height);
  video.loadPixels();
  delay(2000);
  for (Repetition=0; Repetition<pics_per_rev; Repetition ++) {
    video.read();
    image(video, 0, 0, width, height);
    video.loadPixels();
    for (int n=0; n<video.width*video.height; n++) {
      video.pixels[n]=video.pixels[n];
    }
    video.updatePixels();
    set(20, 20, video);
    String file_name="raw_image-"+nf(Repetition+1, 3)+".png";// this the orginal
    video.save(file_name);
  }
  noLoop();
}

how to save images using this code

ive left comments in the code :wink:

thank you i see and read but could not do it that why i asked

edit
@paulgoux give me some explanation if you pleas