Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headless scenario error: _tkinter.TclError: no display name and no $DISPLAY environment variable #5

Open
0b1-k opened this issue Jan 3, 2014 · 7 comments

Comments

@0b1-k
Copy link

0b1-k commented Jan 3, 2014

When using infrapix on a Raspberry Pi from the command line, the following error occurs. It would be great to be able to use infrapix in headless scenarios. Thanks and regards.

root@hgbnoircam:/home/hygrowbot/pics# infrapix_single -i 2014-01-02-17:28:16.337740.jpg --show_histogram -o ndvi.jpg
Rendering infrablue input image '2014-01-02-17:28:16.337740.jpg' to NDVI output image 'ndvi.jpg'
2014-01-02-17:28:16.337740.jpg ndvi.jpg
Converting to NDVI...
Traceback (most recent call last):
File "/usr/local/bin/infrapix_single", line 9, in
load_entry_point('infrapix==dev', 'console_scripts', 'infrapix_single')()
File "/usr/local/lib/python2.7/dist-packages/infrapix-dev-py2.7.egg/infrapix/commands/single.py", line 139, in main
app.render()
File "/usr/local/lib/python2.7/dist-packages/infrapix-dev-py2.7.egg/infrapix/commands/single.py", line 43, in render
self.render_single(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/infrapix-dev-py2.7.egg/infrapix/commands/single.py", line 53, in render_single
ndvi(self.input_file,self.output_file,**self.ndvi_kwargs)
File "/usr/local/lib/python2.7/dist-packages/infrapix-dev-py2.7.egg/infrapix/process_infrablue.py", line 115, in ndvi
fig=plt.figure(figsize=(fig_w,fig_h),dpi=dpi)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 343, in figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

@rperezperez
Copy link

Hello,

try with this:

  1. nano /usr/local/lib/python2.7/dist-packages/infrapix-dev-py2.7.egg/infrapix/process_infrablue.py
  2. append the following code:

import matplotlib
matplotlib.use('Agg')

before the line:
import matplotlib.image as mpimg

  1. save the file

Best,
Ramón

@0b1-k
Copy link
Author

0b1-k commented Jan 19, 2014

Thank you Ramón :)
I'll give this a try this weekend and will report back.
Cheers,
-Fabien.

@0b1-k
Copy link
Author

0b1-k commented Jan 20, 2014

Hi Ramón,

I made the suggested change to the /src/process_infrablue.py then rebuilt, re-installed, and ran a test with the fix.

During the test, the following warning messages showed up but the code didn't crash :) Yay! Progress :)

root@hgbnoircam:/home/hygrowbot/pics# infrapix_single -i latest.jpg --show_histogram -o latest_noir.jpg
Rendering infrablue input image 'latest.jpg' to NDVI output image 'latest_noir.jpg'
latest.jpg latest_noir.jpg
Converting to NDVI...
/usr/local/lib/python2.7/dist-packages/infrapix-dev-py2.7.egg/infrapix/process_infrablue.py:79: RuntimeWarning: invalid value encountered in divide
arr_ndvi = num/denom
/usr/lib/pymodules/python2.7/matplotlib/colorbar.py:686: RuntimeWarning: invalid value encountered in greater
in_cond = (xn > -0.001) & (xn < 1.001)
/usr/lib/pymodules/python2.7/matplotlib/colorbar.py:686: RuntimeWarning: invalid value encountered in less
in_cond = (xn > -0.001) & (xn < 1.001)
/usr/lib/pymodules/python2.7/matplotlib/colors.py:533: RuntimeWarning: invalid value encountered in less
cbook._putmask(xa, xa<0.0, -1)

We're on the right track, however, the resulting image was nearly entirely black as you can see below:

latest_noir

@rperezperez
Copy link

Hi Fabien,

do you remember if you moved the camera while taking the picture? I have
sometimes the same effect, but I rebooted it and it was solved the
problem :(

Best,
Ramón

Fabien Royer wrote:

Hi Ramón,

I made the suggested change to the /src/process_infrablue.py then
rebuilt, re-installed, and ran a test with the fix.

During the test, the following warning messages showed up but the code
didn't crash :) Yay! Progress :)

root@hgbnoircam:/home/hygrowbot/pics# infrapix_single -i latest.jpg
--show_histogram -o latest_noir.jpg
Rendering infrablue input image 'latest.jpg' to NDVI output image
'latest_noir.jpg'
latest.jpg latest_noir.jpg
Converting to NDVI...
/usr/local/lib/python2.7/dist-packages/infrapix-dev-py2.7.egg/infrapix/process_infrablue.py:79:

RuntimeWarning: invalid value encountered in divide
arr_ndvi = num/denom
/usr/lib/pymodules/python2.7/matplotlib/colorbar.py:686:
RuntimeWarning: invalid value encountered in greater
in_cond = (xn > -0.001) & (xn < 1.001)
/usr/lib/pymodules/python2.7/matplotlib/colorbar.py:686:
RuntimeWarning: invalid value encountered in less
in_cond = (xn > -0.001) & (xn < 1.001)
/usr/lib/pymodules/python2.7/matplotlib/colors.py:533: RuntimeWarning:
invalid value encountered in less
cbook._putmask(xa, xa<0.0, -1)

We're on the right track, however, the resulting image was nearly
entirely black as you can see below:

latest_noir
https://f.cloud.github.com/assets/1403215/1957481/995b4a8c-8209-11e3-8553-6f60c8da1d04.jpg


Reply to this email directly or view it on GitHub
#5 (comment).

@0b1-k
Copy link
Author

0b1-k commented Feb 6, 2014

Hi Ramón,

The source images aren't the issue:

. the IR camera itself is rigged at a fixed location and never moves
. the IR images themselves are perfectly clear and focused

It's only when processing the IR pictures through the infrapix code with the recommended changes

import matplotlib
matplotlib.use('Agg')

that the color mapping stops working (see the Runtime warnings)

I hope this clarifies things a bit.

Thank you,

Best regards,
-Fabien.

@hardtoneselector
Copy link

same issue here, running on odroid u3 (modified ubuntu) but not in a headless enviroment.
with the imort mathlib I was get rid of the tkinter error and then i recieved the black screen,...
@fabien: did you found a workarround?
Thanks
Best Regards
Bernhard

@0b1-k
Copy link
Author

0b1-k commented Apr 11, 2014

Hi Bernhard,

Unfortunately, this issue had to be put on the back burner and I did not investigate it any further, at least for the time being.

Best regards,
-Fabien.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants