How to set OpenCv Environment Variable and Path Variable on a Mac? - opencv

I am doing a tutorial on how to install and use Opencv with Cmake. I have gotten through to a step that says Set OpenCV_DIR environment variable to path to Opencv install folder and the directly after Set Path variable where Opencv is installed. I am lost and all the tutorials / solutions I have looked at seem outdated or do not work. Please could someone show me how to do this. Thanks so much for any help.

If you are using Windows, the quick way is to open CMake GUI application and change the variable wherever you want. For a Mac/Linux machine, command line might be your best choice, and this thread will be really helpful for you.

Related

Modifying HAProxy Lua Library Path

I am trying to load Lua script from HAProxy. In the Lua script, the following line is causing an error:
local http = require("socket.http")
Intially I gathered from journalctl -xe output that the library was not installed. I installed it using luarocks install luasocket. This did not solve the issue. The new error is module "socket.http" not found. Following the comment in this post I realized that I must change the settings for Lua library path in order to resolve this issue.
Now, I want to know the following:
Do I have install HAProxy+Lua from source and modify the library path pre installation?
If building from source is not necessary then, I believe I must change the path using syslog as suggested by the comment from post linked above. If this is the case, how do I do that and what settings do I need to change/add to syslog.conf?
Are there are any other solution that I am overlooking which, would easier than any of the above?
Thanks for your help in advance.
EDIT 1
I have modified both LUA_PATH and LUA_CPATH as follows:
LUA_PATH=/usr/bin/lua;/usr/bin/lua5.3;/usr/share/lua/5.3/ltn12.lua;/usr/share/lua/5.3/mime.lua;/usr/share/lua/5.3/socket.lua;/usr/share/lua/5.3/ssl.lua;/usr/share/lua/5.3/posix/_argcheck.lua;/usr/share/lua/5.3/posix/compat.lua;/usr/share/lua/5.3/posix/deprecated.lua;/usr/share/lua/5.3/posix/init.lua;/usr/share/lua/5.3/posix/sys.lua;/usr/share/lua/5.3/posix/util.lua;/usr/share/lua/5.3/posix/version.lua;/usr/share/lua/5.3/socket/ftp.lua;/usr/share/lua/5.3/socket/headers.lua;/usr/share/lua/5.3/socket/http.lua;/usr/share/lua/5.3/socket/smtp.lua;/usr/share/lua/5.3/socket/tp.lua;/usr/share/lua/5.3/socket/url.lua;/usr/share/lua/5.3/term/colors.lua;/usr/share/lua/5.3/term/cursor.lua;/usr/share/lua/5.3/term/init.lua;/usr/share/lua/5.3/ssl/https.lua;/usr/share/lua/5.3/luarocks/add.lua;/usr/share/lua/5.3/luarocks/admin_remove.lua;/usr/share/lua/5.3/luarocks/build.lua;/usr/share/lua/5.3/luarocks/cache.lua;/usr/share/lua/5.3/luarocks/cfg.lua;/usr/share/lua/5.3/luarocks/command_line.lua;/usr/share/lua/5.3/luarocks/config_cmd.lua;/usr/share/lua/5.3/luarocks/deps.lua;/usr/share/lua/5.3/luarocks/dir.lua;/usr/share/lua/5.3/luarocks/doc.lua;/usr/share/lua/5.3/luarocks/download.lua;/usr/share/lua/5.3/luarocks/fetch.lua;/usr/share/lua/5.3/luarocks/fs.lua;/usr/share/lua/5.3/luarocks/help.lua;/usr/share/lua/5.3/luarocks/index.lua;/usr/share/lua/5.3/luarocks/install.lua;/usr/share/lua/5.3/luarocks/lint.lua;/usr/share/lua/5.3/luarocks/list.lua;/usr/share/lua/5.3/luarocks/loader.lua;/usr/share/lua/5.3/luarocks/make.lua;/usr/share/lua/5.3/luarocks/make_manifest.lua;/usr/share/lua/5.3/luarocks/manif_core.lua;/usr/share/lua/5.3/luarocks/manif.lua;/usr/share/lua/5.3/luarocks/new_version.lua;/usr/share/lua/5.3/luarocks/pack.lua;/usr/share/lua/5.3/luarocks/path_cmd.lua;/usr/share/lua/5.3/luarocks/path.lua;/usr/share/lua/5.3/luarocks/persist.lua;/usr/share/lua/5.3/luarocks/purge.lua;/usr/share/lua/5.3/luarocks/refresh_cache.lua;/usr/share/lua/5.3/luarocks/remove.lua;/usr/share/lua/5.3/luarocks/repos.lua;/usr/share/lua/5.3/luarocks/require.lua;/usr/share/lua/5.3/luarocks/search.lua;/usr/share/lua/5.3/luarocks/show.lua;/usr/share/lua/5.3/luarocks/site_config.lua;/usr/share/lua/5.3/luarocks/type_check.lua;/usr/share/lua/5.3/luarocks/unpack.lua;/usr/share/lua/5.3/luarocks/upload.lua;/usr/share/lua/5.3/luarocks/util.lua;/usr/share/lua/5.3/luarocks/validate.lua;/usr/share/lua/5.3/luarocks/write_rockspec.lua;/usr/share/lua/5.3/luarocks/build/builtin.lua;/usr/share/lua/5.3/luarocks/build/cmake.lua;/usr/share/lua/5.3/luarocks/build/command.lua;/usr/share/lua/5.3/luarocks/build/make.lua;/usr/share/lua/5.3/luarocks/fs/lua.lua;/usr/share/lua/5.3/luarocks/fs/tools.lua;/usr/share/lua/5.3/luarocks/fs/unix.lua;/usr/share/lua/5.3/luarocks/fs/win32.lua;/usr/share/lua/5.3/luarocks/fetch/cvs.lua;/usr/share/lua/5.3/luarocks/fetch/git_file.lua;/usr/share/lua/5.3/luarocks/fetch/git_http.lua;/usr/share/lua/5.3/luarocks/fetch/git_https.lua;/usr/share/lua/5.3/luarocks/fetch/git.lua;/usr/share/lua/5.3/luarocks/fetch/git_ssh.lua;/usr/share/lua/5.3/luarocks/fetch/hg_http.lua;/usr/share/lua/5.3/luarocks/fetch/hg_https.lua;/usr/share/lua/5.3/luarocks/fetch/hg.lua;/usr/share/lua/5.3/luarocks/fetch/hg_ssh.lua;/usr/share/lua/5.3/luarocks/fetch/sscm.lua;/usr/share/lua/5.3/luarocks/fetch/svn.lua;/usr/share/lua/5.3/luarocks/tools/patch.lua;/usr/share/lua/5.3/luarocks/tools/tar.lua;/usr/share/lua/5.3/luarocks/tools/zip.lua;/usr/share/lua/5.3/luarocks/upload/api.lua;/usr/share/lua/5.3/luarocks/upload/multipart.lua
LUA_CPATH=/usr/lib64/lua/5.3/posix/ctype.so;/usr/lib64/lua/5.3/posix/dirent.so;/usr/lib64/lua/5.3/posix/errno.so;/usr/lib64/lua/5.3/posix/fcntl.so;/usr/lib64/lua/5.3/posix/fnmatch.so;/usr/lib64/lua/5.3/posix/glob.so;/usr/lib64/lua/5.3/posix/grp.so;/usr/lib64/lua/5.3/posix/libgen.so;/usr/lib64/lua/5.3/posix/poll.so;/usr/lib64/lua/5.3/posix/pwd.so;/usr/lib64/lua/5.3/posix/sched.so;/usr/lib64/lua/5.3/posix/signal.so;/usr/lib64/lua/5.3/posix/stdio.so;/usr/lib64/lua/5.3/posix/stdlib.so;/usr/lib64/lua/5.3/posix/syslog.so;/usr/lib64/lua/5.3/posix/termio.so;/usr/lib64/lua/5.3/posix/time.so;/usr/lib64/lua/5.3/posix/unistd.so;/usr/lib64/lua/5.3/posix/utime.so;/usr/lib64/lua/5.3/mime/core.so;/usr/lib64/lua/5.3/socket/core.so;/usr/lib64/lua/5.3/socket/serial.so;/usr/lib64/lua/5.3/socket/unix.so;/usr/lib64/lua/5.3/term/core.so;/usr/lib64/lua/5.3/ssl.so;/usr/lib64/lua/5.3/zlib.so
I am still getting the same error as reported before.
EDIT 2
Found this post on Lua require function quite helpful. Following the discussion, I tried the following:
package.path="/usr/share/lua/5.3/?/?.lua"
package.cpath="/usr/lib64/lua/5.3/?/?.so"
I added these lines at the top my lua script that's causing the error. I also modified the environment variables, LUA_PATH and LUA_CPATH with the same value. The error still persists.
I am out of all possible options at this stage and would be glad if someone can shed some light on this issue.

Error installing ORB-SLAM2 on Windows

I'm interested in ORB-SLAM2, So I searched and found this site
https://github.com/Phylliida/orbslam-windows <<
so I read the README file and copied it, but I found these errors.
enter image description here
I already installed OPENCV on windows and I set up the environment variables well.
How can I fix errors?
Try setting OpenCV_DIR in CMakeLists.txt
SET("OpenCV_DIR" "C:/opencv")
If you want an automated installation, build setup for ORB-SALM2, we have it in this repo, scripts\windows\bootstrap.batbuilds opencv and dependencies using vcpkg and build.bat compiles ORB-SLAM2. Bootstrap usually takes time for first time!!
1.Adding the variable to the system path like this.
2.Setting the variable by the cmake-gui.Then reconfigure.
3.Setting the include and lib path about opencv in the CMakeLists.txt manually.

Set environment variables on Mac OS X Sierra?

For example, I want to follow this guide on how to disable Brew analytics (under warning) but I have no idea how to find my environmental variables.
Most of the guides out there I found, such as this one, are all outdated; ~/.bash_profile doesn't exist according to how the answer described it. Can some please explain to a new MacOS user how all this now works?
Please note my understanding of Unix-based filesystems are limited. Treat me as a noob.
You can create ~/.bash_profile. The easiest way to create it is to use the touch utility: touch .bash_profile . It is common to have a .profile which is read if bash can not find .bash_profile. You can get the documentation from a terminal with man bash. You can edit either of these files with any text type editor (not word processor).
In case you're using zsh like me, you need to modify ~/.zshrc
I Android Gradle project root I do
gradle app:assembleDebug --stacktrace
but I get error
Minimum supported Gradle version is 5.4.1. Current version is 5.1.
and message says
/gradle/wrapper/gradle-wrapper.properties to gradle-5.4.1-all.zip
but it is
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
so why is Gradle not building?

compile gpu samples at ubuntu by terminal [duplicate]

Recently I'm learning openCV. I followed the tutorial on openCV website.
http://docs.opencv.org/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html#howtoscanimagesopencv
However, when I compile my code using following command
g++ loadImage.cpp -o loadImage
the command line shows:
fatal error: 'opencv2/core/core.hpp' file not found
#include <opencv2/core/core.hpp>
^
I installed openCV with brew, I think it is OK. Then I use emacs to edit and g++ compile my code directly, is that the problem? I searched some similar problems but they refer to xCode environment. Thanks for your help!
You need to tell g++ where it can find the header files. I recommend you setup either eclipse or any other IDE that can handle that stuff for you (like Qt Creator or many others). You can follow the setup guides for OpenCV for instructions, if needed.
[edit: note that I know that emacs can also be setup to handle things like include and library paths, but I have no idea how, hence my recommendation for a full scale IDE]
You can also specify the path to the includes on the command line with -I, then it should also work. Example:
g++ -I/path/to/OpenCV-2.4.9/build/include loadImage.cpp -o loadImage
There are environment variables you can set so you don't have to specify this for every call (see this page for a complete list, specifically CPATH and it's variants might be of interest.
So I find an answer myself, using cmake! How did I miss that..
http://docs.opencv.org/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html#linux-gcc-usage

Need help configuring ImageMagick

I've directly downloaded the tar file from here onto my desktop for Mac OSX (which is what I'm using) and extracted its contents. Now I've read the following instructions on how to set it up, but honestly they're a bit too cryptic for me. I was wondering if anyone could please break down these instructions into simpler, bite size pieces for someone who typically has trouble configuring new things...
I'd truly appreciate any help! Thanks!
Btw, my end goal is to set this up for the Paperclip plugin.
The first step would be to install MacPorts if you don't have it already. Once MacPorts is installed it should be fairly straightforward based on the instructions listed at the link you provided.
sudo port install ImageMagick
For others interested in this topic, I might look into installing homebrew instead of MacPorts.

Resources