Code Monkey home page Code Monkey logo

calcam's Introduction

Calcam logo

Calcam Python Package

Calcam is a Python package providing tools for "spatial calibration" of cameras used in science & engineering, i.e. determining the mapping between pixel coordinates in an image and real-world 3D sight lines & coordinates. The calibration method is based on the user matching features between an image to be calibrated and a 3D mesh of the scene being viewed, then using OpenCV’s camera calibration routines to fit a model relating the image and real world coordinates.

It was written for use with camera-based plasma diagnostics on fusion experiments, but may be useful for other applications too. As well as calibrating existing cameras, it can also be used as part of a virtual diagnostic setup, e.g. to evaluate different possible viewing geometries during diagnostic design and/or setting up synthetic imaging diagnostics for modeling codes.

Calcam provides a set of GUI tools for calibrating images and doing some basic analysis using the results, and a Python API for making full use of the calibration information as part of a data analysis process.

Documentation

The full documentation for the latest release version is online at: https://euratom-software.github.io/calcam/

or can be found in the docs/ directory in the source repo.

License

Calcam is released under the European Union Public Licence (EUPL) v1.1, full details in the included LICENCE.txt

Citing

If using this software for published academic work, please cite it! It has a DOI issued by Zenodo; click the DOI badge below for full details of how to cite.

DOI

calcam's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

calcam's Issues

Rendering in original coords

Error when passing Coords='original' to calcam.render.render_cam_view:

File "/home/ssilburn/Python/calcam/calcam/render.py", line 290, in render_cam_view
OutputImage = FitResults.transform.display_to_original_image(OutputImage)
File "/home/ssilburn/Python/calcam/calcam/coordtransformer.py", line 122, in display_to_original_image
data_out = cv2.resize(data_out,(self.x_pixels/binning,self.y_pixels/binning),interpolation=cv2.INTER_NEAREST)
TypeError: integer argument expected, got float

Update & document geometry matrix module

The geometry matrix module was basically un-touched by the Calcam 2 upgrade and should be updated, possibly with a nice GUI. Needs discussion with jrh and KL11 tomography users. Also this module needs proper documentation.

GUI doesn't update until next interaction

In both the point picker and CAD definition GUIs, elements don't update until the next GUI interaction.

Eg. loading of images, CAD models, image enhancements, zooming in CAD and creation/movement of control points don't update until a different tab is clicked, another control point is placed, or another checkbox/button is pressed.

Version numbers:
Calcam: 2.4.0 on win32 using Enthought Canopy 2.1.9.3717
VTK: 7.0.0
OpenCV: 4.1.1
PyQT: 5.13.1

Bug in view tree with multi-FOV cameras

When trying to click a sub-field of a split FOV calibration in the viewport tab, the code seems to try to load a calibration filename based on the sub-FOV name rather than the main save name. For example:

Traceback (most recent call last):
File "/home/pc/calcam/bin/calcam/gui.py", line 944, in change_cad_view
view = fitting.VirtualCalib(str(view_item.text(0)))
File "/home/pc/calcam/bin/calcam/fitting.py", line 1088, in init
self.load(SaveName)
File "/home/pc/calcam/bin/calcam/fitting.py", line 1174, in load
SaveFile = open(os.path.join(paths.virtualcameras,SaveName + '.pickle'),'rb')
IOError: [Errno 2] No such file or directory: '/home/pc/calcam/VirtualCameras/Sub FOV # 1.pickle'

Split field editor broken in fixes_jan_2018 branch

In the fixes_jan_2018 branch, the split field editor crashes as soon as it tries to add the VTKActor to the renderer. The crash comes from somewhere inside VTK, no python exceptions raised. Seems to happen on both Windows and Linux.

Image masking for calibrations

It would be very useful to be able to add an image mask to a calibration to indicate pixels which do not actually contain good information, e.g. due to the image not filling the detector or something not in the CAD model blocking the view of some pixels.

get_ray_end raises exception with coords='Original'

When calling get_ray_data with no pixel coordinate arguments in order to return the ray end coordinates for the whole image as follows:

surface_coords = ray_data.get_ray_end(coords='Original')

the following exception is raised when coords='Original':

File "/home/tfarley/repos/calcam/calcam/raycast.py", line 609, in get_ray_end return self.transform.display_to_original_image(self.ray_end_coords) File "/home/tfarley/repos/calcam/calcam/coordtransformer.py", line 215, in display_to_original_image raise Exception('Expected (multiple of) {:d}x{:d} pixel image, got {:d}x{:d}!'.format(expected_size[0],expected_size[1],image.shape[1],image.shape[0])) Exception: Expected (multiple of) 256x320 pixel image, got 320x256!

This exception is not raised and the function performs as expected if either specific pixel coordinates are supplied, or coords='Display' i.e. the error only occurs when returning the full frame of 'Original' ray end coordinates.

Calcam: v2.4.1

Segmentation fault on initialization of Virtual calib editor and manual alignment editor on Mac-Os

I believe this is fairly specific to Mac-OS. I am using Mac-OS 10.14.2, and VTK 8.1.2

I think the segfault occurs in instances where the editor attempts to pre-load the CAD model whilst rendering the initial window.

I can prevent the segfault by commenting out the two calls

self.refresh_3d()

and

self.refresh_3d()

however this is just treating a symptom. I think the root cause must be in some issue that VTK has on Mac-Os with the initial render in these two cases, and it seems like its related to the cases where it attempts to preload the cad model (I think....)

Is it possible to prevent these two editors from pre-loading the CAD model?

Option to fix vertical cross section in 3D viewer GUI

It would be really nice to be able to select a check box in the 3D viewer GUI to force the cross-section cut to always be in a vertical plane (perhaps just through the origin if the cursor is more difficult) rather than the default of the plane whose normal is the viewing direction.

I don't know how difficult this would be to implement, but it would enable some really nice figures where you have a cross section of the machine, but could have a tilted view eg looking down at the divertor tiles you are interested in.

Bugs when loading new images during calibration

When loading a new image during point pair fitting calibration:

  • The fit is reset but "show wireframe overlay / show fitted points" remain enabled
  • No checking of number of sub-views or sub-view mask is made

"Edge Type" no longer working but not removed

When using the wireframe-ish CAD rendering, the "detect" method is now always used, but the options relating to "simple" are still all present and should be either removed or their functionality be re-instated.

Inverse distortion model fitting

Add fitting of "inverse" distortion model to calibration class. This is needed by Timo for real-time un-distortion for the MAST-U detachment control.

Inaccurate results from render_cam_view() on VTK versions 8.2+

calcam.render_cam_view() currently gives inaccurate results if using VTK 8.2.0 or newer. This makes it extremely difficult to do calibrations using the GUI because CAD wireframe overlays, which are produced using render_cam_view(), are not accurate and therefore misleading. First reported by Jordan Cavalier, confirmed on both Linux & Windows up to VTK 9.0.1.

Image points not rendering

Image points in calibration tool are invisible!

Happens in Windows under Enthought Canopy, with: Python 3.5.2, OpenCV 3.2.0-2, VTK 7.0.0-2, PyQt 4.12-1

ALso in OpenSUSE with Python 3.4.6, VTK 7.0.0, PyQt 4.8.6, OpenCV 3.1.0.

Exception after browing for CAD model directory in Python 2

When opening a GUI tool which prompts to browse or define CAD models under Python 2.x, an exception is raised after browsing for the location. This is due to the path coming back as a QString in Python 2.x and ending up with a QString in CalcamConfig.cad_def_paths.

Fitting tool allows "Do Fit" with too few points

If using chessboard images, the fitting tool enables the "Do Fit" button with any number of point pairs. However, if a fit is attempted with fewer than 4 points an exception is raised by OpenCV.

A minimum of 4 points for a fit must be enforced.

File name field in image sources

An exception is raised when clicking the "Browse..." button of an image source unless file name is the last parameter specified in the get_image_arguments list of the image source. This seems to be because of the way the lambda to which the

button is connected is constructed.

Standalone intrinsics calibration tool

It would probably be useful to have a GUI for performing intrinsics-only i.e. lab chessboard calibrations, which can then be used to constrain other calibrations, as the basis for virtual calibrations etc. This could also be used in the place of the current chessboard images dialog. Would probably also want to create a new calibration subclass for this.

Broken depth ordering / 3D rendering on some machines

There is a long-standing problem where the 3D rendering is badly broken (faces missing, parts out-of-order in depth, etc) on some (but not all) unix systems.

Testing on Linux Mint, it looks like this is related to the embedding of VTK in PyQt. The two attached files in vtk_minimal_test.zip illustrate the problem - two scripts which render an identical scene, one using a VTK window directly (works fine) and one using QVTKRenderWindowInteractor (shows broken rendering).

Improving image - fit overlay clarity

It can be difficult to compare the image and overlay - possibly add ability to draw high contrast guide lines over the image, or have the overlay semi-trsnaprent and improve contrast of the image display?

Fitting after 90 degree rotation

When doing a 90 degree rotation of both image + point pairs on a set of point pairs which otherwise fit very well, the fitting then does not work properly. If rotating another 90 degrees (to 180) it works OK again.

Distinguish raycast rays that don't intersect surfaces

Currently if a raycast point passes through a port or hole in the CAD model, the length of the returned ray is a function of the CAD dimensions and can be confusing to the user. It would be helpful if these ray lengths and end coords are returned as eg nans.

Ability to use non-chessboard intrinsics patterns

Being able to use a bright-squares-on-dark-background type pattern for intrinsics calibration (see attached image) would enable chessboard-like intrinsics calibration for IR cameras. Suggested by Andy Thornton.
squares

Enabling "Colour by material" before loading CAD model doesn't work

Ticking the "colour by material" checkbox before loading a CAD model causes an exception and doesn't colour the model once it's loaded. Example:

Traceback (most recent call last):
File "/home/pc/calcam/bin/calcam/gui.py", line 402, in set_cad_colour_by_material
self.cadmodel.colour_by_material(colour_by_material)
AttributeError: 'NoneType' object has no attribute 'colour_by_material'

Non-straight sightlines in image analyser

In the image analyser, for non-visible points the displayed sight-line direction seems to change at the ray-model intersection point. This happens for both continuations of sight-lines and sight-lines towards non-visible points. Not clear whether this is an issue with the image analyser or accuracy of project_points and/or the ray casting.

gui run bug

after installation and running gui, no buttons are active (opens and closes a window with no log/output)
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.