Sibi
Sibi

Reputation: 2421

Lua image errors

I have installed lua image according to this - link. I also tested my install with luajit -limage -e "image.test()" and it says 0 errors and 0 warnings. Also, when I try

> require 'image'
> l = image.lena()

There are no errors. However, when I try image.display(l), I get the following errors:

/home/srilatha/torch/install/share/lua/5.1/trepl/init.lua:384: module 'qt' not found:No LuaRocks module found for qt
    no field package.preload['qt']
    no file '/home/srilatha/.luarocks/share/lua/5.1/qt.lua'
    no file '/home/srilatha/.luarocks/share/lua/5.1/qt/init.lua'
    no file '/home/srilatha/torch/install/share/lua/5.1/qt.lua'
    no file '/home/srilatha/torch/install/share/lua/5.1/qt/init.lua'
    no file './qt.lua'
    no file '/home/srilatha/torch/install/share/luajit-2.1.0-beta1/qt.lua'
    no file '/usr/local/share/lua/5.1/qt.lua'
    no file '/usr/local/share/lua/5.1/qt/init.lua'
    no file '/home/srilatha/.luarocks/lib/lua/5.1/qt.so'
    no file '/home/srilatha/torch/install/lib/lua/5.1/qt.so'
    no file '/home/srilatha/torch/install/lib/qt.so'
    no file './qt.so'
    no file '/usr/local/lib/lua/5.1/qt.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
    [C]: in function 'error'
    /home/srilatha/torch/install/share/lua/5.1/trepl/init.lua:384: in function 'require'
    /home/srilatha/torch/install/share/lua/5.1/image/init.lua:1363: in function 'display'
    [string "_RESULT={image.display(l)}"]:1: in main chunk
    [C]: in function 'xpcall'
    /home/srilatha/torch/install/share/lua/5.1/trepl/init.lua:651: in function 'repl'
    ...atha/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x00406670  

I have torch running properly so I don't know what the problem would be with qt. How can I fix this?

Upvotes: 4

Views: 2618

Answers (2)

Tomasz Gandor
Tomasz Gandor

Reputation: 8833

Just to add to Piglet's answer - read about qlua:

https://github.com/torch/qtlua/blob/master/doc/qt.md#qlua

At first I thought: "Oh dear, I'm using luajit, in a torch installation, I have no time and motivation to install another interpreter, configure luarocks to work with it, and then install everything from scratch". Good news: I was wrong.

qlua is an interpreter, but it gets installed in your existing Lua + Torch directory.

$ luarocks install qtlua
$ luarocks install qttorch
$ which qlua
/home/me/torch/install/bin/qlua
$ qlua
Lua 5.1 Copyright (...)
> require('image')
> l = image.lena()
> image.display(l)
> 

.. a window pops up, and the prompt returns immediately.

This is because qlua has a background GUI thread to display your images and react to events (closing, and resizing the window, upon which the image will be scaled - with no aspect preservation: W & H independent).

Upvotes: 2

Piglet
Piglet

Reputation: 28964

Did you read this by any chance?

https://github.com/torch/image/blob/master/doc/gui.md

image.display among other functions can only be accessed via the qlua Lua interpreter.

Calling that function from LuaJit will result in the errors you're facing.

Upvotes: 4

Related Questions