colorply.mm3d¶
colorply.mm3d.calibration¶
Class object for calibration definition. Note that class objects are heavy weight in python, therefore these class won’t be (always) used in the main core of colorply.
colorply.mm3d.functional¶
Read and extract informations from MicMac xml calibration files. Functional implementation.
-
colorply.mm3d.functional.
read_S
(nameIMGxml)[source]¶ This function extracts the images’s center from the xml file.
Note
Usually, it is “Orientation-Im[n°i].JPG.xml”
Parameters: nameIMGxml (str) – The name of the file generated by MM3D. Returns: Center of the IMG, of shape 1x3 Return type: np.ndarray
-
colorply.mm3d.functional.
read_calib
(calibxml)[source]¶ This function extracts the calibration parameters from the xml file.
Note
Usually, it is similar to “AutoCal_[Focal]_[CameraName].xml”
Parameters: calibxml (str) – Name of the camera calibration file Returns: Returns F, PPS, distorsion coefficients a, b, c, size Return type: dict
-
colorply.mm3d.functional.
read_calib_F
(calibxml)[source]¶ This function extracts the calibration parameters from the xml file.
Note
Usually, it is similar to “AutoCal_[Focal]_[CameraName].xml”
Parameters: calibxml (str) – Name of the camera calibration file Returns: Coordinates of the point F (focale, units : pix) Return type: np.ndarray
-
colorply.mm3d.functional.
read_calib_PPS
(calibxml)[source]¶ This function extracts the calibration parameters from the xml file.
Note
Usually, it is similar to “AutoCal_[Focal]_[CameraName].xml”
Parameters: calibxml (str) – Name of the camera calibration file Returns: Coordinates of the PPS, of shape 1x3 Return type: np.ndarray
-
colorply.mm3d.functional.
read_calib_distorsion
(calibxml)[source]¶ This function extracts the calibration parameters from the xml file.
Note
Usually, it is similar to “AutoCal_[Focal]_[CameraName].xml”
Parameters: calibxml (str) – Name of the camera calibration file Returns: Distorsion coefficients [a, b, c] Return type: np.ndarray
-
colorply.mm3d.functional.
read_ori
(nameIMGxml)[source]¶ This function extracts the rotation matrix from the xml file and extracts the images’s center from the xml file.
Note
Usually, it is “Orientation-Im[n°i].JPG.xml”
Parameters: nameIMGxml (str) – The name of the file generated by MM3D. Returns: The rotation of the img, the center of the IMG, tuple(np.array(matrix rotation), np.array(coord S)) Return type: tuple
-
colorply.mm3d.functional.
read_orientation
(nameIMGxml)[source]¶ This function extracts the rotation matrix from the xml file.
Parameters: - nameIMGxml (str) – name of the file generated by MM3D.
- note:: (.) – Usually, it is “Orientation-Im[n°i].JPG.xml”
Returns: Rotation of the img, of shape 3x3
Return type: np.ndarray
colorply.io¶
colorply.io.imfile¶
Load a set of images with their orientation.
-
colorply.io.imfile.
load_images
(orientation_dir, image_dir='.', image_ext='TIF', channel='unk')[source]¶ Reads all images and returns a list of image objects
Parameters: - orientation_dir (str) – orientation directory of MicMac files
- image_dir (str) – image directory
- image_ext (str) – image extensiton (ex: ‘TIFF’)
- channel (str) – name of the channel
Returns: Return type: list(Image)
colorply.io.ply¶
Contains reading and writing functions for ply files as well as a conversion function and other useful functions related to ply files
-
colorply.io.ply.
add_channel_from_plydata
(plydata, coord, channel)[source]¶ Add a channel to the numpy data.
Parameters: - plydata (plyfile.PlyData) – Raw data.
- coord (numpy.ndarray) – The coordinates of the 3D points.
- channel (str) – Name of the channel to add.
Returns: data – DESCRIPTION.
Return type: TYPE
-
colorply.io.ply.
extract_channel_from_plydata
(plydata, channel='all')[source]¶ Extract a channel from a 3D cloud points.
Parameters: - plydata (plyfile.PlyData) – The data to extract the channel.
- channel (str, optional) – The name of the channel to extract. The default is “all”.
Returns: data – The extracted channel data.
Return type: numpy.ndaray
-
colorply.io.ply.
plydata_to_array
(plydata)[source]¶ Convert a plydata to numpy array.
Parameters: plydata (plyfile.PlyData) – The plydata to convert. Returns: The converted data, containing the 3D coordinates of the plydata’s points. Return type: numpy.ndarray
-
colorply.io.ply.
read_plyfile
(file_name)[source]¶ Read and extract the data of a ply file.
Parameters: file_name (str) – The path to the ply file. Raises: FileNotFoundError
– If the file is not found, raises an error.Returns: plydata – The data of the cloud points file. Return type: plyfile.PlyData
-
colorply.io.ply.
write_plydata
(plydata, data_channel, new_channel_name, outfile_name='my_cloud.ply')[source]¶ Create a ply file from plydata. Can add an additional channel to the plydata.
Parameters: - plydata (plyfile.PlyData) – The plydata to write in the file.
- data_channel (numpy.ndarray) – Data of the added channel.
- new_channel_name (str) – Name of the new added channel.
- outfile_name (str, optionnal) – Name of the ply file created. The default is “my_cloud.ply”.
Returns: Return type: None
colorply.io.readxml¶
-
colorply.io.readxml.
read_S
(nameIMGxml)[source]¶ This function extract the images’s center from the xml file.
Parameters: nameIMGxml (str) – the name of the file generated by MM3D. Usually, it is “Orientation-Im[n°i].JPG.xml” Returns: numpy.ndarray Return type: the center of the IMG (size 1*3)
-
colorply.io.readxml.
read_calib
(calibxml)[source]¶ This function extract the calibration parameters from the xml file.
Parameters: calibxml (str) – the name of the calibration file generated by MM3D (ex: “AutoCal_Foc-24000_Cam-DSLRA850.xml”) Returns: tuple Return type: F, PPS, distorsion coefficients a, b, c, size
-
colorply.io.readxml.
read_calib_F
(calibxml)[source]¶ This function extract the calibration parameters from the xml file.
Parameters: calibxml (str) – the name of the calibration file generated by MM3D. (ex: “AutoCal_Foc-24000_Cam-DSLRA850.xml”) Returns: numpy.ndarray Return type: coordinates of the point F (focale, units : pix), (size 1*)
-
colorply.io.readxml.
read_calib_PPS
(calibxml)[source]¶ This function extract the calibration parameters from the xml file.
Parameters: calibxml (str) – the name of the calibration file generated by MM3D (ex: “AutoCal_Foc-24000_Cam-DSLRA850.xml”). Returns: numpy.ndarray Return type: coordinates of the PPS (size 1*3)
-
colorply.io.readxml.
read_calib_distorsion
(calibxml)[source]¶ This function extract the calibration parameters from the xml file.
Parameters: calibxml (str) – the name of the calibration file generated by MM3D (ex: “AutoCal_Foc-24000_Cam-DSLRA850.xml”). Returns: numpy.ndarray Return type: distorsion coefficients a, b, c (size 1*3)
-
colorply.io.readxml.
read_ori
(nameIMGxml)[source]¶ This function extract the rotation matrix from the xml file and extract the images’s center from the xml file.
Parameters: nameIMGxml (str) – the name of the file generated by MM3D. Usually, it is “Orientation-Im[n°i].JPG.xml” Returns: tuple Return type: the rotation of the img, the center of the IMG, (matrix rotation, coord S)
-
colorply.io.readxml.
read_orientation
(nameIMGxml)[source]¶ This function extract the rotation matrix from the xml file.
Parameters: nameIMGxml (str) – the name of the file generated by MM3D. Usually, it is “Orientation-Im[n°i].JPG.xml” Returns: numpy.ndarray Return type: the rotation of the img (size 3*3)
colorply.process¶
colorply.process.image¶
Defines an Image, with its orientation, focal, symmetry.
-
class
colorply.process.image.
Image
(name='None', channel='None', data=<sphinx.ext.autodoc.importer._MockObject object>, R=<sphinx.ext.autodoc.importer._MockObject object>, S=<sphinx.ext.autodoc.importer._MockObject object>, size=(4000, 3000))[source]¶ Define an image, with its name, channels, data, rotation and autocollimation.
colorply.process.imformula¶
This modules contains the necessary functions to compute the image formula for each “ground” point.
-
colorply.process.imformula.
image_formula
(F, M, R, S)[source]¶ Compute the image formula for the point M withoud distorsion
Parameters: - F (numpy.ndarray) – Position of the autocollimation point in the image coordinate system.
- M (numpy.ndarray) – Position of the point in real space coordinates.
- R (numpy.ndarray) – Rotation matrix representing the orientation of the image coordinate system in the real space coordinate system.
- S (numpy.ndarray) – Position of the autocollimation point in the real space coordinate system.
Returns: Image coordinates of M projected.
Return type: numpy.ndarray
-
colorply.process.imformula.
image_formula_corrected
(F, M, R, S, pps, a, b, c)[source]¶ Compute the image formula for the point M with distorsion.
Parameters: - F (numpy.ndarray) – Position of the autocollimation point in the image coordinate system.
- M (numpy.ndarray) – Position of the point in real space coordinates.
- R (numpy.ndarray) – Rotation matrix representing the orientation of the image coordinate system in the real space coordinate system.
- S (numpy.ndarray) – Position of the autocollimation point in the real space coordinate system.
- pps (numpy.ndarray) – Position of the point of 0 distorsion ine the radial_std model.
- a (float) – 3rd order coefficient of the distorsion polynomial.
- b (float) – 5th order coefficient of the distorsion polynomial.
- c (float) – 7th order coefficient of the distorsion polynomial.
Returns: Corrected point position.
Return type: numpy.ndarray
-
colorply.process.imformula.
radial_std
(m_image, pps, a, b, c)[source]¶ Corrects the postion of the point according to the standard radial distorsion model.
Note
We use Horner’s method to evaluate \(ar^2 + br^4 + cr^6\)
Parameters: - m_image (numpy.ndarray) – Position of the projected point in pixel.
- pps (numpy.ndarray) – Position of the point of 0 distorsion in the radial model.
- a (float) – 3rd order coefficient of the distorsion polynomial.
- b (float) – 5th order coefficient of the distorsion polynomial.
- c (float) – 7th order coefficient of the distorsion polynomial.
Returns: Corrected point position.
Return type: numpy.ndarray
colorply.process.improcess¶
Module to preprocess images.
-
colorply.process.improcess.
add_cloud_channel
(input_ply, output_ply, calibration_file, orientation_dir, image_dir, image_ext='TIF', channel='unk', mode='avg', progress=None)[source]¶ All together. Project all points from a ply file.
Parameters: - input_ply (plydata) – The cloud points to add a new channel.
- output_ply (plydata) – The output cloud points, with the new channel.
- calibration_file (str) – Path to the MicMac calibration file.
- orientation_dir (str) – Path to the MicMac images orientation directory.
- image_dir (str) – Path to the images with the channel to add.
- image_ext (str, optional) – Images extension (JPG, TIFF, PNG etc.). The default is “TIF”.
- channel (str, optional) – Channe name. The default is “unk”.
- mode (str, optional) – Way to add the new radiometry to the cloud points. The default is “avg”.
- progress (PyQt progress bar, optional) – The bar of progress. The default is None.
Raises: FileNotFoundError
– If files are not found, raise an error.Returns: Return True when done.
Return type: Bool
-
colorply.process.improcess.
radiometry_projection
(M, images_loaded, calibration, mode='avg', scale=0.0038909912109375)[source]¶ This function add to a point M a new channel, computed from the loaded images. Therefore, the images should be calibrated in the same reference of your point M. Usually, the 3D point M is part of a cloud points. The point M is projected in all images that see the point. Then, the radiometry from the images channel is added to the point, with different mode.
Parameters: - M (numpy.ndarray) – Position of the point in real space coordinates.
- images_loaded (list of Images) – List of the image loaded. These images need to be referenced in the same system as the point M. Usually with MicMac calibrate all the images together.
- calibration (dict) – dict containing the camera calibration global parameters.
- mode (str, optional) – The way the new radiometry is stacked in the new M channel. This can be with a mean of all radiometry that see the 3D point M. The default is “avg”.
- scale (float) – Used to scale a channel to [0, 255] values. For Sequoia camera, use a scale factor of 0.0038909912109375.
Returns: Value of the new channel.
Return type: float
colorply.ui¶
colorply.ui.call¶
This module recieves instruction from the ui and call the appropriate functions on the appropriate parameters.
colorply.ui.gui¶
This is the python-colorply GUI.
-
class
colorply.ui.gui.
MainWindow
[source]¶ -
-
initUI
()[source]¶ Initialyze the window with different buttons and actions.
Returns: Return type: None.
-
select_calib_dir
()[source]¶ Select the MicMac calibration directory from the window.
Returns: Return type: None.
-
colorply.ui.palette¶
Set colors and theme to the interface.