Methods for Lua to invoke OPENCV
Recently, I want to use Lua to call OPENCV for related pixel-level operations, such as: Bitwise_and or Bitwise_or, to complete the image IoU calculation.
So, how do you invoke Opencv with Lua?
After checking the official documents of Torch, I found only so few packages that could be called:
Links: https://github.com/torch/torch7/wiki/Cheatsheet
Then, you click on one to go in and discover that there is a way to install the corresponding OPENCV package:
then, you enter in the terminal: luarocks install CV , found half a day did not respond ...
After a while, there was a reaction, see:
then, is waiting for, this "turtle speed" really can not endure!!!
In fact, here is not so direct, because, you find that if you do not download the OPENCV official software package, install the time, will prompt you wrong, thus stop!
So, it is necessary to install the process of prompting on this webpage:https://github.com/VisionLabs/torch-opencv/wiki/Installation
The first is to download and install the OPENCV official 3.1 Linux version file;
Then, make sure your Torch is no problem;
And then start to execute just that sentence: Luarocks install CV, here, if you can directly specify the path of the Opencv file, it is better, that is:
Example: opencv_dir= "/home/wangxiao/opencv-3.1.0" luarocks install CV
Then, you can do, just wait, wait, wait ...
Assuming that the installation is complete, you can test it to see if it is normal:
1 --require ' CV '2 --require ' cv2 '3 require 'Torch'4 require 'Image'5 require 'Display'6 require "LFS"7 require "Xlua"8 require 'nn'9 require 'Optim'Ten require 'Torch' One AImageFile ='/home/wangxiao/pictures/screen/gamersky_01origin_01_201610151947336.jpg' - LocalIMG = image.Load(ImageFile,3,'byte') -img = Image.scale (IMG,224,224) the Image.display (IMG) - -GT_X1 =Ten -Gt_y1 = - +GT_X2 = - -Gt_y2 = $ +Gt_patch = Image.crop (IMG,Tonumber(GT_X1),Tonumber(Gt_y1),Tonumber(GT_X2),Tonumber(gt_y2)) A Image.display (Gt_patch) at -X1 =Ten -Y1 = - -x2 = - -y2 = - -Pred_patch = Image.crop (IMG,Tonumber(x1),Tonumber(y1),Tonumber(x2),Tonumber(y2)) in Image.display (Pred_patch) - to --Compute the IoU of the Gt_patch and Pred_patch.
Not finished, to be continued ... My OPENCV is also in the installation ...
Methods for Lua to invoke OPENCV