Giter Club home page Giter Club logo

Comments (6)

poynting avatar poynting commented on May 18, 2024

It's hard to know what's going on without seeing the failing code. Is it possible that you haven't implemented the radiometric corrections that are implemented in cell #2 of the alignment tutorial prior to running align_capture?

If you have questions about the radiometric corrections, please refer to the earlier tutorials where they are described in detail. It would be a good start to ensure you can run the Alignment notebook on the provided data. Then substitute your own data, and try to determine what might be different.

https://github.com/micasense/imageprocessing/blob/master/Alignment.ipynb

In the future an issue report should always contains at minimum the following elements:

  1. Title/Description
  2. Environment (including all code that is failing)
  3. Steps to reproduce
  4. Expected Result(s)
  5. Actual Result(s)

from imageprocessing.

poynting avatar poynting commented on May 18, 2024

It may not be obvious from the alignment tutorial, but the library lazy-computes reflectance images within a Capture object only when they are needed. In the tutorial, the

capture.plot_undistorted_reflectance(panel_irradiance)

method ensures this computation is done. If plotting is not necessary, instead call

capture.compute_reflectance(panel_irradiance)

where panel_irradiance is computed using panel image radiance and the provided panel reflectance values (which are different for every panel) by calling

capture.panel_irradiance(panel_reflectance)

and panel_reflectance is a list of panel reflectance values in the range 0-1 for each band, in RedEdge band_index order (not wavelength order).

from imageprocessing.

SmithPeng avatar SmithPeng commented on May 18, 2024

Firstly, the problem is how to calibrate raw images from the camera into reflectance maps

(1).https://github.com/micasense/imageprocessing/blob/master/MicaSense%20Image%20Processing%20Tutorial%201.ipynb

As (1) described, from raw images to radiance worked as following:

import micasense.utils as msutils
radianceImage, L, V, R = msutils.raw_image_to_radiance(meta, imageRaw)

convert radiance to reflectance worked as following:

Select panel region from radiance image , some codes are omitted
meanRadiance = panelRegion.mean()
panelReflectance = panelCalibration[bandName]
radianceToReflectance = panelReflectance / meanRadiance
reflectanceImage = radianceImage * radianceToReflectance

(2).https://github.com/micasense/imageprocessing/blob/master/Alignment.ipynb

As (2) described,from raw images to reflectance worked as following:

panel_irradiance = panelCap.panel_irradiance(panel_reflectance_by_band)
capture.plot_undistorted_reflectance(panel_irradiance)

from raw images to radiance, in 'panel_irradiance()',

irradiance_list = []
for i,p in enumerate(self.panels):
mean_irr = p.irradiance_mean(reflectances[i])
irradiance_list.append(mean_irr)

where

def irradiance_mean(self, reflectance):
radiance_mean, _, _, _ = self.radiance()
return radiance_mean * math.pi / reflectance

convert radiance to reflectance worked as following,in 'plot_undistorted_reflectance',

self.reflectance(irradiance_list)

and in (2), 'self.radiance()' equal to 'msutils.raw_image_to_radiance()' in (1), reflectances[i] in (2) equal to 'panelCalibration[bandName]' in (1), self.panels in (2) equal to panelRegion in (1) .
In (1), transform coefficient from radiance to reflectance is radianceToReflectance , in (2), transform coefficient is irradiance_list, is 'mean_irr' in (2) equal to 'meanRadiance' in (1)?

I haven't seen something like 'panelRegion.mean()', how could 'radiance_mean' in (2) represent the mean of radiance image?

from imageprocessing.

SmithPeng avatar SmithPeng commented on May 18, 2024

Secondly, you are right ! I comment out the following line and errors behind appear.
capture.plot_undistorted_reflectance(panel_irradiance)
just after add 'compute_reflectance', code go through.
capture.compute_reflectance(panel_irradiance)

but in this step
warp_matrices, alignment_pairs = imageutils.align_capture(capture, max_iterations=100)
error appeared as following

Alinging images. Depending on settings this can take from a few seconds to many minutes
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib64/python3.6/multiprocessing/spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "/usr/lib64/python3.6/multiprocessing/spawn.py", line 114, in _main
prepare(preparation_data)
File "/usr/lib64/python3.6/multiprocessing/spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "/usr/lib64/python3.6/multiprocessing/spawn.py", line 277, in _fixup_main_from_path
run_name="mp_main")
File "/usr/lib64/python3.6/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/pengyaoyao/project/uav_registration/imageprocessing/test.py", line 34, in
warp_matrices, alignment_pairs = imageutils.align_capture(capture, max_iterations=10)
File "./micasense/imageutils.py", line 117, in align_capture
multiprocessing.set_start_method('spawn')
File "/usr/lib64/python3.6/multiprocessing/context.py", line 242, in set_start_method
raise RuntimeError('context has already been set')
RuntimeError: context has already been set

Environment

python3.6

from imageprocessing.

poynting avatar poynting commented on May 18, 2024

I think your first question is answered in https://github.com/micasense/imageprocessing/blob/master/micasense/panel.py#L144
where self here is a Panel object, so it has a defined region if a panel is found in the image or if the corners are provided at initialization.

    def radiance(self):
        radiance_img = self.image.undistorted(self.image.radiance())
        return self.region_stats(radiance_img,self.panel_corners())

Your second issue is likely that you're re-running the alignment code in the same notebook without re-starting the kernel. multiprocessing.set_start_method('spawn') can only be called once in a program.

The solution is probably to "restart and run all" in your notebook. This is a terrible feature of jupyter notebooks; they save state and tend to hide it from the developer. Many times notebook problems can be fixed with "restart and run all."

from imageprocessing.

SmithPeng avatar SmithPeng commented on May 18, 2024

first question is OK

second issue is solved, too.

When using spawn I should guard the part that launches the job in
if __name__ == '__main__':
.set_start_method should also go there, and everything run fine.

from imageprocessing.

Related Issues (20)

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.