Skip to content

Commit

Permalink
Disable interpolation for SFM.
Browse files Browse the repository at this point in the history
Updated README.md.
Prepared for release.
  • Loading branch information
zlogic committed May 16, 2023
1 parent d80ce50 commit 1687106
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cargo-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Cargo build

on:
push:
branches: [ "master", "multi-view-reconstruction" ]
branches: [ "master" ]
pull_request:
branches: [ "master" ]

Expand Down
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# Cybervision

# Experimental multi view branch

**⚠️ Warning** This `multi-view-reconstruction` is an experimental branch, attempting to reconstruct 3D images from a set of photos.
Unfortunately, it requires either camera calibration, or using [advanced math for self-calibration](https://www.researchgate.net/publication/3659897_The_modulus_constraint_A_new_constraint_self-calibration) - solving a quartic equation system with up to 64 roots.
It's a bit too much and out of my scope of expertise.
Without calibration, each pair of images uses its own coordinate system and it's impossible to align images in a single 3D model.
It also doesn't help that sometimes noise or incorrectly detected features cause images to be incorrectly reconstructed, and adding that data to a combined mesh ruins the end result.

![Build status](https://github.com/zlogic/cybervision/actions/workflows/cargo-build.yml/badge.svg)

<img src="https://raw.githubusercontent.com/wiki/zlogic/cybervision/Cybervision.svg" width="100"/>
Expand All @@ -17,7 +9,7 @@ Cybervision is a 3D reconstruction software for Scanning Electron Microscope ima
The tool needs two images of an object taken from slighly different angles.
Cybervision can match those images and use the parallax effect to determine the object's 3D shape.

⚠️ Cybervision works best with high-contrast images with parallel (affine) projection.
**⚠️ Warning** Cybervision works best with high-contrast images with parallel (affine) projection.
Regular photos with perspective projection can be reconstructed as well, but this is a secondary use case.

More information is available in the [Wiki](https://github.com/zlogic/cybervision/wiki).
Expand Down Expand Up @@ -62,10 +54,13 @@ Adding this flag can significantly reduce processing time, at the cost of produc
* If the filename ends with `.png`, this will save a PNG depth map file.
* If the filename ends with `.jpg`, this will save a JPEG depth map file.

⚠️ The optimal image size is 1024x1024 (or similar).
**⚠️ Warning** The optimal image size is 1024x1024 (or similar).
Using larger images will result in increased processing times, increased memory usage, and run into GPU hardware limitations.
Smaller images might not have enough details.

**⚠️ Warning** Structure-from-motion (attempting to reconstruct 3D images from a set of photos) works, but the results are often full of noise.
Unfortunately, it requires either camera calibration, which depends on complicated math - a bit too much for me and out of my scope of expertise.

### GPU details

Compiling a GPU-accelerated (Vulkan) version requires additional libraries and build tools.
Expand Down
27 changes: 27 additions & 0 deletions src/reconstruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use nalgebra::DMatrix;
use nalgebra::Matrix3;
use rayon::prelude::*;
use std::error;
use std::fmt;
use std::fmt::Write;
use std::fs::File;
use std::io::BufReader;
Expand Down Expand Up @@ -198,6 +199,13 @@ pub fn reconstruct(args: &Cli) -> Result<(), Box<dyn error::Error>> {
triangulation,
};

if args.img_src.len() > 2 && interpolation_mode != output::InterpolationMode::None {
return Err(ReconstructionError::new(
"Interpolation should be none when reconstructing from more than 2 images",
)
.into());
}

for i in 0..args.img_src.len() - 1 {
let img1_filename = &args.img_src[i];
let img2_filename = &args.img_src[i + 1];
Expand Down Expand Up @@ -563,3 +571,22 @@ impl output::ProgressListener for ProgressBar {
self.set_position((pos * 10000.0) as u64);
}
}

#[derive(Debug)]
struct ReconstructionError {
msg: &'static str,
}

impl ReconstructionError {
fn new(msg: &'static str) -> ReconstructionError {
ReconstructionError { msg }
}
}

impl std::error::Error for ReconstructionError {}

impl fmt::Display for ReconstructionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.msg)
}
}

0 comments on commit 1687106

Please sign in to comment.