OpenCV and dlib Face detection - anaconda

I am using the code mentioned in the link :
OpenCV detect face landmarks (ear-chin-ear line)
I executed it on Anaconda Python3.5 using opencv3 and dlib but I get the following error :
rect=dlib.rectangle(x,y,x+w,y+h) which is Boost.Python.ArgumentError: Python argument types in rectangle.__init__(rectangle, numpy.int32, numpy.int32, numpy.int32, numpy.int32) did not match C++ signature: __init__(_object*, long left, long top, long right, long bottom) __init__(_object*)
I changed the type of the parameters using :
x,y,w,h =rects[0].astype('long')
But the same error persists. Kindly help.

Dlib comes with complete example programs that show how to do this. You should refer to that code since it's correct: http://dlib.net/face_recognition.py.html
Also, here are other python example programs. They all run correctly: https://github.com/davisking/dlib/tree/master/python_examples

Related

Installing toolboxes in Octave

In order to realise some course's activity in Octave, found in the following site
https://nbviewer.org/github/gpeyre/numerical-tours/blob/master/matlab/audio_1_processing.ipynb#
I needed to install some toolboxes found in
http://www.numerical-tours.com/installation_matlab/
Two of them seems to be easily installed via pkg install -forge ... (I have Linux Mint 19), these toolboxes are 'general' and 'signal', but 'graph' and 'wavelet_meshes' seems not to be directly available for Octave.
1 - So, if I downloaded them manually.. how should I install these packages? I do not even find Octave directory using 'whereis' in order to localise a proper folder to throw toolboxes files (its path shown located in /app/share/octave when open).
2 - Another thing.. should I spect to use toolboxes automatically after toolbox is installed? or may I indicate its selection in some specific way? ..I ask this because after running the following script chunk
n = 1024*16;
options.n = n;
[x,fs] = load_sound('bird', n);
command window throws the following message
error: 'load_sound' undefined near line 3, column 4
so I understand Octave does not recognises 'load_sound' function, which is from 'signal' toolbox (that is already installed).
Any suggestions?

Installing IPOPT nonlinear solvers

I am trying to install ipopt with anaconda on Windows10 x64.
I already installed ipopt via "conda install -c conda-forge ipopt" in the anaconda prompt (version=3.13.4).
I built a small test-script in python to check my installation:
import pyomo.environ as pe
import pyomo.opt as po
M = pe.ConcreteModel()
M.x = pe.Var()
M.y = pe.Var(bounds=(0, None))
M.obj = pe.Objective(expr=M.x+M.y, sense=pe.minimize)
M.c1 = pe.Constraint(expr=(M.x >=4)) // this constraint expr will be replaced by M.x**2 >= 4 to test nonlinear problems
M.c2 = pe.Constraint(expr=(M.y >= M.x))
solver = po.SolverFactory('ipopt')
results = solver.solve(M, tee=True)
print(pe.value(M.x), pe.value(M.y))
Running the script, I received the following error message:
ApplicationError: No executable found for solver 'ipopt'
I could solve this problem downloading the zip-folder for 64-bit windows from https://ampl.com/products/solvers/open-source/ and extracting the files into the "Library"-folder of the anaconda environment I am working on.
Running the test script for the linear problem again, the problem is solved but I get the following information:
This is Ipopt version 3.12.13, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).
The nonlinear test problem, however, cannot be solved as still the linear mumps solver is applied.
EXIT: Maximum Number of Iterations Exceeded.
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";
- termination condition: maxIterations
- message from solver: Ipopt 3.12.13\x3a Maximum Number of Iterations
Exceeded.
M.x=-281240.49215541 M.y=13.01195537079578
How can I make sure that nonlinear problems are solved by ipopt as well? I am aware that there are a few similar questions on stackoverflow, but I wasn't able to solve my problem yet.
(I also tried to follow the installation guide from https://coin-or.github.io/Ipopt/INSTALL.html, but encountered the message "configure: error: no acceptable C compiler found in $PATH""" in the MSYS2 console when I tried to install ASL or HSL, even though I installed gcc as described and included the folder which contains gcc.exe into my PATH-variable.)
Probably the conda-forge package doesn't include the AMPL interface and the ipopt executable that is required by Pyomo (at least, that is the case for https://anaconda.org/conda-forge/ipopt/3.13.4/download/win-64/ipopt-3.13.4-hf6be2e5_0.tar.bz2).
MUMPS should not be the reason if Ipopt failed to solve min x+y s.t. x>=4, y>=x. One would need to inspect the Ipopt log to see what is going wrong.
If you feel that the executable from ampl.com is too old, you can try the ones that are attached to the Ipopt releases, e.g., https://github.com/coin-or/Ipopt/releases/download/releases%2F3.14.1/Ipopt-3.14.1-win64-msvs2019-md.zip for the latest.
They also include Pardiso from MKL in addition to MUMPS.
To check why the compiler check in configure failed under msys2, have a look into file config.log that is generated by configure.

Fault in reticulate in rstudio

476/5000
rstudio generates error when running R code with python code. At first the code worked very well but in the second installation it started to generate faults. Here is the link of the code in case you want to play #https: //www.r-bloggers.com/r-and-python-using-reticulate-to-get-the-best-of-both-worlds/
. My laptop is hp 4 gigs of ram and 500 mb of hard disk.
I would greatly appreciate who can explain the failure and how to solve it.
I have reinstalled anaconda last version twice.
library(reticulate)
use_python("/usr/local/bin/python")
use_virtualenv("r-reticulate")
os <- import("os")
Error: lexical error: invalid char in json text.
WARNING: The conda.compat modul
(right here) ------^
os$listdir(".")
Error: object 'os' not found
py_config()
Error: lexical error: invalid char in json text.
WARNING: The conda.compat modul
(right here) ------^
Actually, it comes from a deprecation warning reported a few days ago (fix compat import showing warning #8507).
But the fact is that this warning in "conda.compat" generates some errors, for example in the case of using conda environments in R through "reticulate" functions. This issue has been reported quite recently Conda warnings taken as errors #477.
The solution is to simply install the github version of "reticulate" in order to avoid these errors and ignore the conda warnings which shouldn't necessarily impede these functionalities. You can do it like this way:
remotes::install_github("rstudio/reticulate")
And don't forget to have the latest Rtools installed in your operating system!
This might be useful for you: https://docs.anaconda.com/anaconda/user-guide/tasks/switch-environment/
I have Anaconda, and set up Python 2 environment. Once activated, run 'use_python' with the path to that environment and set the 'required' parameter to TRUE.
I had the same problem. I solved the problem by installing an older version of conda.
In anaconda promt
conda install conda = 4.1.6

pyinstaller gives weird errors when compiling pandas

UPDATE june 18:
I would like compiling my python code for windows.
I use to work with pyinstaller, python 3.5+, windows 7 and anaconda to control modules pandas, pyqt (v5) and pyqtgraph, but it seems something is not compatible. I would not be surprised if you tell me to change a version.
In previous versions, it worked with python 3.5, windows 7 and Pyinstaller 3.3.1- without pandas; the new version imports pandas and then this doesn’t work anymore:
with the usual config pyinstaller gives a message saying the C libraries are not built. Following the instructions, I should run python setup.py build_ext --inplace --force, except I don’t see the setup.py file, so I don’t know what to do. Forums tell me it should be a problem with pip but not with conda… but I use conda…
with python 3.6, I got an error message ‘RecursionError: maximum recursion depth exceeded’ (https://github.com/steph2016/profiles/blob/master/errorMessage). This problem seems known and solutions I found on forums is either to downgrade python or to replace my PyInstaller-3.3.1 by PyInstaller-3.4.dev0+7b3143612. But with PyInstaller-3.4.dev0+7b3143612 I get a ’’str’ object has no attribute ‘items’’ error (https://github.com/steph2016/profiles/blob/master/ErrorMessage2). I’m not sure pyinstaller is compatible with python 3.6…
with python 3.4, I got an error similar to the ‘str object’ one above. I’m not sure python3.4 is compatible with qt5…
I would be pleased by any solution with any version of whatever to windows-compile my code
I don't know if it is the issue but I didn't find PyQtGraph in Supported-Packages
I eventually applied the first solution proposed in No module named 'pandas._libs.tslibs.timedeltas' in PyInstaller in the original config (python 3.5, PyInstaller 3.3.1, pyqtgraph, pandas, windows 7,...) and it worked.
I don't know why adding def get_pandas_path ..... a.binaries) helps, so I can't justify. But just to be explicit even if it seems obvious: pyinstaller must be run on the spec file, not on the py one (for instance > pyinstaller toto.spec)

correct SWI_HOME_DIR value?

I encountered error:
"FATAL ERROR: Could not find system resources"
I then added the following code:
putenv("SWI_HOME_DIR=/usr/lib/swi-prolog");
I ran into another problem of:
"$c_call_prolog...Undefined procedure"
(More details here)
I ran the below command on Ubuntu 10.12
sudo apt-get install swi-prolog build-essential.
I wrote a simple C program to test it but was not able to retrieve the return value from prolog. Suppose I want to interact with mortal.pl, I compiled with:
swipl-ld -o mmm mortal.c mortal.pl
no error but like I mentioned. I did not get what I expected.
I obtained another code, nothing weird on the code. This time I got the first error. It seems that if swi-prolog is set to that directory, it won't search for my predicate.
Where and what should I set this SWI_HOME_DIR?
(Recap) with
putenv("SWI_HOME_DIR=/usr/lib/swi-prolog");
I called
mmm socrates
I got
$c_call_prolog...Undefined procedure
w/o putenv, the same call returned
FATAL ERROR: Could not find system resources
I finally changed
PL_initialise(1, plav)
where plav[0] = "mortal"; plav[1] = NULL; to
PL_initialise(1, argv)
I am able to obtain True/False from
rval = PL_call_predicate(NULL, PL_Q_NORMAL, pred, h0);
Though this confuses myself. What does PL_initialise() expect then?...not a to be called predicate?
No solution. I ended up installing ubuntu 12.10 64 bits (previously 32 bit). All those weird behavior are gone.

Resources