尝试索引全局 'cv'(零值)

Attempt to index global 'cv' (a nil value)

OS: ubuntu

我正在尝试使用 cv 包中的函数检测给定图像中对象的边缘。

首先,我 运行 'qlua' 在我的 ubuntu 终端。

local cv = reuqire 'cv'
require 'cv'
reuqire 'image'
lena_p = image.load('/home/stone/codes/lena1.jpg')
image.dispaly(lena_p)
cv.rectangle{lena_p,{5,5},{10,10},color = {30,30,180},thickness = 2}
ca_l = cv.Canny{image=limg,threshold=1,threshold=10}

但是,它失败并出现以下错误:

[string "cv.rectangle{lena_p,{5,5},{10,10},color = {30..."]:1: attempt to index global 'cv' (a nil value) stack traceback: [string "cv.rectangle{lena_p,{5,5},{10,10},color = {30..."]:1: in main chunk [C]: at 0x7f6be51eaba0

[string "ca_l = cv.Canny{image=limg,threshold=1,thresh..."]:1: attempt to index global 'cv' (a nil value) stack traceback: [string "ca_l = cv.Canny{image=limg,threshold=1,thresh..."]:1: in main chunk [C]: at 0x7feb66429ba0

我的问题是,如何使用'cv'包中的函数来检测物体轮廓?

参考: https://github.com/VisionLabs/torch-opencv/tree/master/cv

您缺少 torch-cv。您可以通过在终端中执行以下命令来安装它:

luarocks install cv