Commit 31d4cc0f authored by Andrey Filippov's avatar Andrey Filippov

Adding new classes

parent 4e6966e0
package com.elphel.imagej.common;
public class MultiThreading {
public static int THREADS_MAX = 100;
/* Create a Thread[] array as large as the number of processors available.
* From Stephan Preibisch's Multithreading.java class. See:
* http://repo.or.cz/w/trakem2.git?a=blob;f=mpi/fruitfly/general/MultiThreading.java;hb=HEAD
*/
public static Thread[] newThreadArray() {
return newThreadArray (THREADS_MAX);
}
public static Thread[] newThreadArray(int maxCPUs) {
int n_cpus = Runtime.getRuntime().availableProcessors();
if (n_cpus>maxCPUs)n_cpus=maxCPUs;
return new Thread[n_cpus];
}
/* Start all given threads and wait on each of them until all are done.
* From Stephan Preibisch's Multithreading.java class. See:
* http://repo.or.cz/w/trakem2.git?a=blob;f=mpi/fruitfly/general/MultiThreading.java;hb=HEAD
*/
public static void startAndJoin(Thread[] threads) // USED in lwir
{
for (int ithread = 0; ithread < threads.length; ++ithread)
{
threads[ithread].setPriority(Thread.NORM_PRIORITY);
threads[ithread].start();
}
try
{
for (int ithread = 0; ithread < threads.length; ++ithread)
threads[ithread].join();
} catch (InterruptedException ie)
{
throw new RuntimeException(ie);
}
}
}
/**
** MultiLayerDSL - Handle multilayer/multivalue disparity/strength/lma values
**
** Copyright (C) 2022 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** TexturedModel.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
package com.elphel.imagej.tileprocessor;
public class MultiLayerDSL {
}
/**
**
** LwocLeaf.java - Octree leaf of the world built from LWIR16 images
**
** Copyright (C) 2022 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** LwocLeaf.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
package com.elphel.imagej.tileprocessor.lwoc;
import java.util.ArrayList;
public class LwocLeaf {
ArrayList <LwocMesh> meshes;
ArrayList <LwocMesh> mesh_centers;
ArrayList <LwocScene> scenes;
public LwocLeaf() {
meshes = new ArrayList <LwocMesh>(); // all meshes BB intersecting this node
mesh_centers = new ArrayList <LwocMesh>(); // mesh centers in this node
scenes = new ArrayList <LwocScene>(); // cameras located in this node
}
public void addScene(LwocScene scene) {
scenes.add(scene);
}
public void addMeshCenter(LwocMesh mesh) {
mesh_centers.add(mesh);
}
public void addMesh(LwocMesh mesh,
boolean check_existed) {
if (!check_existed || meshes.contains(mesh)) {
meshes.add(mesh);
}
}
public ArrayList <LwocMesh> getMeshes(){
return meshes;
}
public ArrayList <LwocMesh> getMeshCenters(){
return mesh_centers;
}
public ArrayList <LwocScene> getScenes(){
return scenes;
}
}
/**
**
** LwocMesh.java - Single mesh of the world built from LWIR16 images
**
** Copyright (C) 2022 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** LwocMesh.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
package com.elphel.imagej.tileprocessor.lwoc;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
public class LwocMesh {
static AtomicInteger MESH_ID = new AtomicInteger();
static ArrayList<LwocMesh> LWOC_MESHES;
int id; // assign unique ID
String stimestamp; // mesh is always referenced to a single scene
double [] world_xyz; // world coordinates of the center
double [] hdims_xyz; // world bounding box half-dimensions along x,y,z
public static void resetMeshes() {
MESH_ID.set(0);
LWOC_MESHES = new ArrayList<LwocMesh>();
}
// maybe use mesh properties instead of id?
public boolean equals (LwocMesh other_mesh) {
return id == other_mesh.id;
}
public LwocMesh(
String stimestamp
) {
this.stimestamp = stimestamp;
id = MESH_ID.getAndIncrement();
LWOC_MESHES.add(this);
}
public double [] getCenter() {
return world_xyz;
}
public double [] getDims() {
return hdims_xyz;
}
}
/**
**
** LwocScene.java - Scene of the world built from LWIR16 images
**
** Copyright (C) 2022 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** LwocScene.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
package com.elphel.imagej.tileprocessor.lwoc;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.tileprocessor.GeometryCorrection;
public class LwocScene {
static AtomicInteger SCENE_ID = new AtomicInteger();
static ArrayList<LwocScene> LWOC_SCENES;
int id; // assign unique ID
String stimestamp;
GeometryCorrection geometryCorrection;
double [] camera_xyz;
double [] camera_atr;
double [] camera_xyz_dt;
double [] camera_atr_dt;
double [][][] tile_layers_dsm; // per tile, per layer, {disparity, strength, mode}. For mode -
// interpret as Double doubleToLongBits(), [22] - used LMA, 0..15 - which sensors were used
public static void resetScenes() {
SCENE_ID.set(0);
LWOC_SCENES = new ArrayList<LwocScene>();
}
public LwocScene (
String stimestamp,
GeometryCorrection geometryCorrection,
double [] camera_xyz,
double [] camera_atr,
double [] camera_xyz_dt,
double [] camera_atr_dt,
double [][][] tile_layers_dsm) {
this.stimestamp = stimestamp;
this.geometryCorrection = geometryCorrection;
this.camera_xyz = camera_xyz;
this.camera_atr = camera_atr;
this.camera_xyz_dt = camera_xyz_dt;
this.camera_atr_dt = camera_atr_dt;
this.tile_layers_dsm = tile_layers_dsm;
id = SCENE_ID.getAndIncrement();
LWOC_SCENES.add(this);
};
// add functionality to save/restore
public double [] getCameraXYZ() {
return camera_xyz;
}
public double [] getCameraATR() {
return camera_atr;
}
public double [] getCameraXYZdt() {
return camera_xyz_dt;
}
public double [] getCameraATRdt() {
return camera_atr_dt;
}
public double [][][] getTileLayersDSM() {
return tile_layers_dsm;
}
public String getTimestamp() {
return stimestamp;
}
public static String getTimestamp(double dts) {
return String.format("%.6f", dts).replace('.', '-');
}
public double getDoubleTimestamp() {
return Double.parseDouble(stimestamp.replace('_', '.'));
}
public static double getDoubleTimestamp(String sts) {
return Double.parseDouble(sts.replace('_', '.'));
}
public int getIntTimestamp() {
return (int) Math.round(1E6*getDoubleTimestamp());
}
public void setTimeStamp(String ts) {
stimestamp = ts;
}
public void setTimeStamp(double dts) {
stimestamp = getTimestamp(dts);
}
public void setTimeStamp(int its) {
stimestamp = String.format("%d_%06d", its / 1000000, its % 1000000);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment