Procedure to build opencv 3.1 from source for Python 3.5 - 32 bit on Windows 10 for Ximea support - windows-10

I had a lot of trouble while building opencv 3.1 from source code with Python 3.5 -32 bit on Windows 10. For any custom build, its a painfully long procedure which has to be followed meticulously. My purpose was to enable Ximea support with OpenCV for which I needed to custom build it.
Now that I have finally nailed it, I have decided to put the complete procedure here in case someone wants to repeat it. Believe me, it will save a lot of trouble. I will post the procedure in the answer.

Procedure to custom build opencv 3.1 for Python 3.5 - 32 bit on Windows 10
Download Python3.5.2
Install numpy (atleast), scipy, matplotlib from http://www.lfd.uci.edu/~gohlke/pythonlibs/. All libraries should be 32-bit version for Python 3.5 version
Install CMake (3.4.1 or later version recommended)
Download opencv3.1 for windows from http://opencv.org/downloads.html
Extract it to a folder where you want to build the library. In this example it is C:\opencv_310
After extracting, you will get two folders - build and source. Pre-build library has support for Python 2.7. We will need to build the library from source code for Python 3.5
Make new folder. In this example, it is named as 'build_custom'
Open CMake and put path for source code 'C:/opencv_310/opencv/sources'
Put path for building the binaries 'C:/opencv_310/opencv/build_custom'
Click Configure
Enter the path for Python3.5
PYTHON3_EXECUTABLE 'C:/Python35/python.exe'
PYTHON3_INCLUDE_DIR 'C:/Python35/lib/site-packages/numpy/core/include'
PYTHON3_LIBRARY 'C:/Python35/libs/python35.lib'
PYTHON3_NUMPY_INCLUDE_DIRS 'C:/Python35/lib/site-packages/numpy/core/include'
PYTHON3_PACKAGES_PATH 'C:/Python35/Lib/site-packages'
In my case, I wanted to enable Ximea camera with OpenCV so I ticked 'WITH_XIMEA'
Untick BUILD_EXAMPLES, BUILD_PERF_TESTS, BUILD_TESTS
Click Configure
Make sure that 'BUILD_opencv_python3' is ticked on. Click Configure again.
Make sure there are no red lines after configure. Now click Generate.
In my case I was trying to get Ximea camera enabled with OpenCV. For that purpose before buliding solution with VisualStudio, make sure you add 'C:\XIMEA\API\x86\' to Environment Variables first.
Go to folder 'C:\opencv_310\opencv\build_custom'
Click on "OpenCV.sln" and open it in Visual Studio (I had VisualStudio 10 installed on my system)
In VisualStudio, make sure you have 'open_python3' in 'bindings' section
Click on Build -> Build Solution. It will take some time to build all the libraries. At the end of build, it should display "29 succeeded, 1 failed"
Number of succeeded build libraries may vary. But for failed, only 1 should fail where python35_d.lib is not found, mainly because Python3.5 doesnt have debug mode library.
Now change from Debug to Release mode and click on the green arrow next to it.
It will build all the libraries in release mode and this time it should say "30 succeeded, 0 failed"
Now environment variables are to be changed. Go to 'My Computer -> Right click -> Properties -> Advanced system settings -> Environment Variables'
In user variables, add NEW, Variable Name = 'OPENCV_DIR', Variable Path = 'C:\opencv_310\opencv\build_custom'
In system variables, add NEW, Variable Name = 'C:\opencv_310\opencv\build_custom\bin'. Click OK
Check if the changes in environment variables are registered. Open command prompt and enter PATH (check for system variable) and system opencv)
Now go to the folder 'C:\opencv_310\opencv\build_custom\lib\python3\Release' and copy 'cv2.cp35-win32.pyd' to 'C:\Python35\Lib\site-packages'
Now go to the folder 'C:\opencv_310\opencv\build_custom\bin\Release' and copy 17 DLLs to ''C:\Python35\Lib\site-packages'
Copy 'opencv_ffmpeg310.dll' from the same folder to 'C:\Python35'
Now go to the directory where Python is installed - "C:\Python35". Open python console by entering 'python'
Once Python console is open, enter 'import cv2'. You should get no error.
Enter 'print(cv2.getBuildInformation())'. It will display all the build properties for OpenCV.
In my case I was trying to get Ximea camera enabled with OpenCV. For that purpose before buliding solution with VisualStudio, make sure you add 'C:\XIMEA\API\x86\' to Environment Variables first.
Or else you will get error while building the solution - 'xiApi.h' not found.
Common errors
1. Make sure everything is 32 bit
Make sure User Variable and System Variable path are correct (This part costed me a lot of time)
Make sure no red lines are present while configuring CMake
Make sure BUILD_opencv_python3 is ticked on
Make sure 'cv2.cp35-win32.pyd' and all 17 DLLs are copied to the right place

Related

Can't use Color Picker Extension in VS Code. [processBridge]: Error: Cannot get NPM

Specs:
Windows 10 Home 21H2
CPU Intel i7-8700k
Motherboard ASUS Prime Z370-P II
Visual Studio Code v1.65.2
Node v16.14.2.
npm v8.5.0
The Problem:
When I run Pick Color ...
This happens
How I got here:
I installed node (and npm) as part of a course, from the official website, to use a TypeScript compiler.
In the process Chocolatey and something about Python was also installed. I think I remember seeing some errors in the script, but I'm very new to all of this. Despite that, both are in paths, as shown later.
Also had to use PowerShell and run
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
I checked the installation
Node version
Now this is what happens when I try to use the Color Picker extension. First, the installation guide says
this.
PATH is ok, as shown in the following pictures.
Node Version Manager? Don't remember using that.
Command Pallete, ext install, "Color Picker" not on the list.
Paths:
User Variables Path and
System Path
VS Code:
Trying ext install in the command pallete
I'm very sorry for this last screenshots in spanish.
Lastly I found this old issue on GitHub but I couldn't solve my problem with it:
(Gonna leave link in the comments as I can't go beyond 8 links in my post.)
Do you need this extension? Probably something buggy that will cause you problems with every upgrade. You already have a similar and cleaner solution as a VSCode default:
Just hover over a color and the little square icon next to it in a CSS or SASS/SCSS file, and you'll see the picker pop up. For changing from RGB(A) to HEX and other types, just click the header where you see rgba(84, ...) in the screenshot.

How to set the NODE_SKIP_PLATFORM_CHECK environment variable to 1 which skips the version check

So earlier I was using node version v13.6 bascially because I am on windows 7 and node.js supports only windows 7 till v13.6 . So what I did was I downloaded the node.js latest version(v14.x.x) in '.zip' package and replaced all the files in the nodejs folder with the newer version file. I also know how to set environment variable but how can I set NODE_SKIP_PLATFORM_CHECK to 1 from the system properties in order to bypass the and run the latest version of node.jsenter image description here?
This work for me
Go to System-Properties (run: systempropertiesadvanced.exe), in
Advanced tab, click Environment Variables.
Still on the System variables, click 'New', add "NODE_PATH" with value "C:\nodejs64\node_modules", and click OK.
click 'New' again, add "NODE_SKIP_PLATFORM_CHECK" with value "1", and click OK.
Click OK of all dialogs close.
Restart your machine, so explore and cmd will get the fresh set of variables.

How can I fix Microsoft Visual C++ 2017 X64 Minimum Runtime error during installing Redistributable packages (VC_redist.x64.exe, VC_redist.x86.exe)?

During installation I get "The feature you are trying to use is on a network resource that is unavailable" and prompt to specify some path to vc_runtimeMinimum_x64.msi. After providing some path to required file I get error states that this file doesn't match required version Minimum Runtime 14.14.26405.
I finally found the solution reading this question: Install vcredist_x64 with VS2017 installer project
I realized that specific VC_Redist.x64.exe files could be downloaded by links like https://aka.ms/vs/15/release/26405.00/VC_Redist.x64.exe, where 26405.00 is exactly the version I was required to fix. Note, that you need version from error text after clicking OK, not from window title.
And the last point is that this exe must be executed from cmd with argument /repair to help me with this issue. Regular execution by double click made no effect.
I found the solution elsewhere. It said to
Fix problems that block programs from being installed or removed
https://support.microsoft.com/en-us/help/17588/windows-fix-problems-that-block-programs-being-installed-or-removed
download troubleshooter button on the link.
Run it - choose option - have problem with installing - it lists programs - choose the missing / problematic visual c++ runtimes in the list
it will run and get fixed.
Repeat for each visual c++ you having problems with. I ran the program multiple times.
I have to thank this comment section for helping me with this problem, since I have not been able to work more efficently with my school, since I din't know what and if a single file somewhere deep down in the computer had to be deleted for this program to work.

Configuring interpreter in PyCharm: "please use a different SDK name"

I have been using Pycharm for years and have never had any problem. However, after my most recent PyCharm update I can no longer configure the interpreter.
Also each time I create a new project it creates a vent directory under my project. When I go to File/Default Settings/Project Interpreter, I am provided with new options.
In this window it allows you to configure a virtual environment, the conda environment, and the system interpreter. I am assuming that I should configure the system interpreter. From there I point PyCharm to the interpreter on my Mac at /usr/local/Cellar/python3/3.6.3/bin/python3 and hit OK.
It then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message:
Cannot Save Settings please use a different SDK name
It doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this?
Interestingly my old projects still work correctly.
I had the same problem while setting up the virtual environment for my project and no matter if I create a new virtual environment or select an existing one, I get the warning:
"Cannot Save Settings please use a different SDK name"
Finally I found the solution:
Click on the project interpreter dropdown and select show all.... There you might be having multiple virtual environments with same name. Now here is the conflict you need to fix manually by renaming them so every item has the unique name.
I ran into this issue when trying to get docker up and running with Pycharm 2018.1 and using the container's Interpreter. I would get the error below.
"Cannot Save Settings please use a different SDK name"
The issue I had was due to having multiple python interpreters of the same name.
Under Pycharm || Preferences || Project Interpreter
Click "show all" within the Project Interpreter dropdown and then delete any / all interpreters that you don't need.
How fix this in Windows 10:
close Pycharm .
delete this file: C:\Users\<username>\.PyCharmCE2018.3\config\options\jdk.table.xml
open Pycahrm again and load all python interceptors again.
Jon; I too noticed the difference in the latest version of PyCharm. It seems that it now has an affinity for the latest tool 'venv'. When you create an interpreter - that is what you get.
You can still create a virtualenv manually and point it there instead. I haven't looked into pointing it to a base python-bin because (frankly) you shouldn't generally do it.
My advice (and my proposed answer) is to embrace the change and let it create a 'venv' for you. From there, do all of your installs by "alt-F12". That will open a console with your virtual environment activate -- so your PIP installs into the virtual environment.
Once I began using virtual environments, I never looked back. It has made life much easier in the python world. Pycharm seems to know this as well and is trying to really encourage you to do the right thing.
SteveJ
[Edit Alternate way to get to terminal]
This may be a known issue of PyCharm and using the method of the accepted answer may not resolve it. Please see https://youtrack.jetbrains.com/issue/PY-27251.
You can close Pycharm and remove jdk.table.xml file from ~/Library/Preferences/.PyCharm2018.1/options directory (Mac version), then start PyCharm again.
Warning: By doing this, all your existing setup of python interpreters will be erased and you need to re-setup them again.
I had same error:
I deleted all invalid project interpreters ( they are red)
then I did https://stackoverflow.com/a/60583928/3842788
You cannot have 2 or more virtual environments with same name. Even if you have projects with same name stored at 2 different places, please give unique name to its venv. This will solve your problem.
To check all the virtual environments:
Go to File >> Settings >> Project: your_project_name >> Project Interpreter
And rename the venv name.
Go to Project > Project Interpreter > Select the dropdown menu > "Show All".
For me, there were several Python environments, two of which were red with an tag. Remove the envs that are red / have an tag, select the remaining valid one, and re-apply settings.
In my case, I moved my project to a different location and PyCharm started complaining about Cannot Save Settings please use a different SDK name. At the top of the main editor, it asks me to Configure Project Interpreter. I clicked it, and then ...
My solution
Remove all existing interpreters that are marked as invalid in the preference.
Select the interpreter in the moved venv subfolder in my project.
Without doing both, I kept getting the same "SDK name" error. It seemed that the project thinks that it already has an interpreter called "python.exe", if you don't actively remove all "invalid" ones.
I solved this issue by cleaning the Pycharm memory cache

GTK+, GLADE, PYTHON 3.6 Windows

I am an Electrical engineer. I am completely new for programming and coding..
Actually i am working as estimation engineer, where i am doing the same estimation again and again with excel.
As same in design stage also i am doing the same again and again.
I thought i will create a application which will automatically do the estimation based on my input. and the same time at the time of design stage it will input from my estimation sheet it will generate the drawing automatically.
(i am doing estimation in excel, preparing drawing in auto cad)
from google, i found the following..
To write a program I need to know a language. so i selected python version 3.6.1
To create a stand alone or micro soft windows installer i selected cx freeze which is converting my code to .exe filex
To create a user interface i selected glade.
But i dont know how to install gtk builder to link pythin code and glade files.
Hopefully you got the point what i am looking..
I am using windiws 10 with 64 bit version
Advance thanks for all
All the information you need on how to install GTK+ and Glade on Windows is on the GTK+ Website.
However, If you're a total beginner, then I suggest you start small, as the kind of work you're describing seems a lot of work for someone who has never written a single line of code.
As suggested by #liberforce, install GTK+ and Glade on Windows from their GTK+ Website. This way you will have an environment (MINGW64) inside which you can practice.
Install python from their download site.
Check also these instructions for how to use it.
The key points (at least for me) are:
Copy the hello.py script you created to C:\msys64\home\<username>
In the mingw32 terminal execute python3 hello.py - a window should appear.
After that, if you want to make an executable, follow these instructions. Try their example for gedit to get some ideas on how to create and how PKGBUILD works (a.k.a. follow the instructions for gedit to see what's happening).

Resources