How can I install opencv with option --with-nonfree using brew - opencv

I installed opencv using brew on Mac. I need some option like nonfree, the command as follows:
brew install opencv --with-nonfree
But, this does't work. It just show:
Warning: opencv: this formula has no --with-nonfree option so it will be ignored!
Must I compile and install opencv from source code?

Homebrew already builds OpenCV with -DOPENCV_ENABLE_NONFREE=ON for you, so you don’t need to specify it:
brew install opencv
Use brew options opencv to get its options. Here it doesn’t output anything because Homebrew doesn’t support any option for that formula.

Related

Gstreamer x265enc missing (homebrew)

On MacOS, I installed GStreamer using the homebrew packages with the command:
brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav
However, I figured that x265enc element, which is supposed to be in gst-plugins-bad, is not installed. Is there any flag etc. to enable its installation? Looking at the the formula code of gst-plugins-bad, I'm unable to understand why it is not installed.

Return to dbt version 19.1

I am not sure how badly I have hosed this. I updated dbt to v20 globally too soon. I did uninstall v20. I need to return the project to version 19.1. I am running into errors doing this. As background I am running a virtual. I am on macos.
These two commands work as expected:
brew tap dbt-labs/dbt
brew unlink dbt
Then I run brew install dbt-labs/dbt/dbt#0.19.1
I get (I expect this) Warning: dbt-labs/dbt/dbt#0.19.1 0.19.1_1 is already installed, it's just not linked. To link this version, run: brew link dbt#0.19.1
Then I run brew link dbt#0.19.1 or brew link dbt-labs/dbt/dbt#0.19.1 and I get:
Error: Formulae found in multiple taps:
* dbt-labs/dbt/dbt#0.12.2-rc1
* fishtown-analytics/dbt/dbt#0.12.2-rc1
Please use the fully-qualified name (e.g. dbt-labs/dbt/dbt#0.12.2-rc1) to refer to the formula.
So I try brew link dbt-labs/dbt/dbt#0.12.2-rc1
Disclosure...I code dbt modules but I do not get too far into the installation since I rarely need to do it. Any help would be highly appreciated.
You might find this issue in the dbt-labs/dbt repo helpful.
TL;DR:
You may be running into issues due to the repo name change. It could help to do a full re-install, i.e.:
brew untap fishtown-analytics/dbt --force
brew tap dbt-labs/dbt
brew install dbt#x.y.z
You can then follow the instructions here as normal for managing several versions with homebrew.

Error during installation of giter8 using Home-brew

I've been trying to install giter8 using brew, like so:
brew install giter8
I get the following error:
Error: giter8 has been disabled because it fetches unversioned dependencies at runtime!
Does anybody know how to fix this, or what workarounds are available. Thank you!
This worked as a workaround for me. No idea if that's the proper fix
Edit the brew formula for giter8:
brew edit giter8
and delete this line
disable! because: "fetches unversioned dependencies at runtime"
The default editor will be vim -- put cursor at that line and hit dd to delete then type :x to save and exit
then re-run brew install giter8 and you should be good
You can create giter8 projects with SBT directly and don't need to install giter8 via Homebrew anymore. sbt new scala/scala-seed.g8 is the example in the docs.
This thread has another workaround (#alexroussos solution also works).
Install giter8
brew install --build-from-source giter8

How do I configure FFTW3 installed via HomeBrew?

I have installed FFTW3 using HomeBrew which downloads the file located at https://homebrew.bintray.com/bottles/fftw-3.3.8_1.mojave.bottle.tar.gz and installs it on my system which is running on macOS 10.14.6. Now, the installation is fine and gcc is able to compile code that uses the fttw3.h header file.
However, there is supposed to be a ./configure script which I should be able to use to customise my configuration and, unfortunately, it does not exist in /usr/local/Cellar/fftw/3.3.8_1.
Where can I find it? How else should I configure the installation?
The build process of a Homebrew package is defined in a file called formula, which is written in Ruby.
A formula is a package definition written in Ruby. It can be created with brew create <URL> where is a zip or tarball, installed with brew install <formula>.
You can get the formula for fftw from homebrew/core/Formula/fftw.rb.
And the configuration options are defined in the args array.
# https://github.com/Homebrew/homebrew-core/blob/e7c8239a8a7c9b4501c4a18a4028cae82e254984/Formula/fftw.rb#L21-L30
def install
args = [
"--enable-shared",
"--disable-debug",
"--prefix=#{prefix}",
"--enable-threads",
"--disable-dependency-tracking",
"--enable-mpi",
"--enable-openmp",
]
Download the fftw.rb formula file and change the configuration options. After that, install the modified formula by building it from source.
brew install --build-from-source local/path/to/modified-fftw.rb
Extended Reading
To get how to write your own formula. Check
Formula Cookbook
How to Create and Maintain a Tap
FAQ
Why brew edit fftw is not recommended?
Homebrew is made of two parts: the brew command and formula repos. fftw.rb is a formula defined in the built-in, local formula repo homebrew-core. When you use brew edit fftw, you are editing the file from the local repo directly. Unless you're going to contribute to this repo, don't edit files within the homebrew-core repo directly.

Installing OpenCV in Ubuntu 14.10

I'm trying to install OpenCV in Ubuntu 14.10 according to instruction.
I installed all mentioned dependencies, but when I'm trying to run make I get such errors:
/home/ilia/opencv-2.4.8/modules/highgui/src/ffmpeg_codecs.hpp:114:7: error: ‘CODEC_ID_H261’ was not declared in this scope
{ CODEC_ID_H261, MKTAG('H', '2', '6', '1') }
for all codecs, as I think.
And these errors:
In file included from /home/ilia/opencv-2.4.8/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/ilia/opencv-2.4.8/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘double CvCapture_FFMPEG::getProperty(int)’:
/home/ilia/opencv-2.4.8/modules/highgui/src/cap_ffmpeg_impl.hpp:773:33: error: ‘AVStream’ has no member named ‘r_frame_rate’
return av_q2d(video_st->r_frame_rate);
^
/home/ilia/opencv-2.4.8/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘double CvCapture_FFMPEG::get_fps()’:
/home/ilia/opencv-2.4.8/modules/highgui/src/cap_ffmpeg_impl.hpp:820:49: error: ‘AVStream’ has no member named ‘r_frame_rate’
double fps = r2d(ic->streams[video_stream]->r_frame_rate);
^
In file included from /home/ilia/opencv-2.4.8/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/ilia/opencv-2.4.8/modules/highgui/src/cap_ffmpeg_impl.hpp: In function ‘int icv_av_write_frame_FFMPEG(AVFormatContext*, AVStream*, uint8_t*, uint32_t, AVFrame*)’:
/home/ilia/opencv-2.4.8/modules/highgui/src/cap_ffmpeg_impl.hpp:1236:72: error: ‘avcodec_encode_video’ was not declared in this scope
out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
^
It looks like it can not find some header files, but I installed all necessary dev packages
libswscale-dev, libavdevice-dev, libavfilter-dev, libavformat-dev, libavcodec-dev. What should I do to resolve these problems?
Installing OpenCV from the Ubuntu repositories is a good choice for the most cases, but sometimes you need build OpenCV from sources yourself.
For example, if you need OpenCV's non-free functionality, or want to contribute to this project (you should use the latest version to create pull request), or want to change something (yes, OpenCV can also contain bugs).
Possible solution is building ffmpeg (it's rather simple) - I really don't understand why Debian/Ubuntu prefers libav without alternative.
For installing ffmpeg you should download its sources from official site or clone GIT repository (git://source.ffmpeg.org/ffmpeg.git), then enter source directory and run
./configure --enable-shared --disable-static
make
sudo make install
you can also add other parameters to configure.
You can build static libraries too, but OpenCV can't be built with static ffmpeg libraries (now I don't know why).
After this you can download OpenCV sources from OpenCV site or clone GitHub repository (OpenCV repository), create build folder and run from it the following:
cmake PATH_TO_SOURCES -DCMAKE_BUILD_TYPE=Release
make
sudo make install
Of course, PATH_TO_SOURCES must be actual path to your OpenCV sources.
After these steps you have working latest OpenCV build in your system.
Unless you have special reasons I would suggest installing the OpenCV that are already in the Ubuntu repository: sudo apt-get install libopencv-dev
For video codecs I suggest simply trying to install all ffmpeg and gstreamer related codec packages.
You can try to build without a ffmpeg:
cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_FFMPEG=OFF ..
make
sudo make install

Resources