Dawid Anioł Blog

Blender build -OSX

  1. Initial requirements. I mean tools which we will use while compilation. XCode application contains compilers C and C++, standard library and necessary header files. All mentioned above is a base for C/C++ environment on OS X platform. Cmake is a tool for building C/C++ projects.

This is a good idea to make a special catalog in which you can keep all source files, additional files, library files and all stuff necessary for compilation.

  • Mkdir blender-build

2. Sources. In this section we download sources of the Blender itself with submodules. Blender sources contain a lot of scripts and configuration files. It contain also files helping with buildup and making packages under various platforms but we are not interested in that yet. We will download the sources first.

  • git clone git://git.blender.org/blender.git

Having Blender sources we need yet submodules. Submodules are sources which for some reason are not included in the main repository, but they have influence for addition functions. As for us to be able to download submodules we should enter to the folder of cloned repository

  • cd blender

And now we can download submodules

  • git submodule update –init –recursive
  • git submodule foreach git checkout master
  • git submodule foreach git pull –rebase origin master

We got submodules now. Next step is to download dependency libraries. Those are complicated static and dynamic files with the headers. These libraries we can compile oureself or download from SVN repository.

  • svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/darwin lib
    • I encountered a problem with braking connection, when downloading some files. You can go back re-download those files but before that you have to cleanup repository
    • cd lib
    • svn cleanup
    • cd ..
    • svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/darwin lib

Downloading might take some time 

3. Compilation. Compilation take place with the command ‚make’, but we can have a few types of this command. 

  • make full – it makes version with all possible options and dependencies
  • Make like – it makes version with minimal number of dependencies 
  • Make headless – it makes version without interface
  • Make deps –  it makes libraries of decency

And this is all, after compilation we have working version of Blender.

Use cv2.compare to background remove.

Background removing is one from the problems in image processing which seem to be pretty easy but gives headache instead. OpenCV library has section dedicated to background removal in videos. BackgroundSubtractorMOG , BackgroundSubtractorMOG2, BackgroundSubtractorGMG are the functions that appears in the library. They remove background from each frame, the mask is made which allow to separate object of interest. Form one side these functions are not perfect. From the other side we oftenly have only two frames, on one of them is only background, and the other frame is the same background but with the object of interests. We can use functions mentioned above or we can go with something lower level which maight be more precise in some cases. 

If given frames are prepared by precision computer image functions meaning that background any shifts and each pixel of the background on one image is equivalent to the other image pixel, also value of these pixels has to be identical. In this case we can use compare function and this is how we can do it:

To make a mask, firstly process image in cvtColor by making it one layer image, and than use compare node with code setting set on CMP_NE. In that step the output image is a small trail with some noise around, which is byproduct of the image compression. Small differences of value of the pixels may depend from the type of compression and its settings. These noise artifacts are removed by erode function. Mask which we achieved has to be process by bitwise function and as effect we can get image without background. These approach is autonomous because it doesn’t require change in settings for other images. 

For background removing we can use another different method which is based on the function watershed. Method is very precise but it required a key regions of the object which we want to separate from the background. But it will be covered in the next article.

Compilation of the code in Python

Sometimes  it is necessary to share application with someone else, and one would like to hide fragments of the code. It is very likely that it will occur on desktop applications, in which user would like to run the program offline. In Python there are some problems with it, because it is interpretable language. As it is at present  in 2018 we don’t have possibility to secure the Python source code from viewing it.

Without going in to much detail, with help of the Python you can „compile” code to the form unreadable for human. „Decompiliation” of such code is not trivial even for advanced users. In most cases, this form is fairly enough.

Compilation of all .py files in current directory :

python -m compileall .

Bibligraphy:

  • http://effbot.org/zone/python-compile.htm
  • https://docs.python.org/3/library/compileall.html#module-compileall

O, o … ImportError: DLL load failed: The specified procedure could not be found.

Problem with DLL files under the Windows system when it comes to using libraries such as numpy or OpenCV it might give you a few problems. Often the problem is lack of standard VisualStudio libraries in which libraries were compiled. Then in this case all you need is Visual C++ redistributable 2015 in the right version or Universal C runtime. If this is not enough and the problem appear which library is missing and in what version it should be.

With help comes two simple tools. Dependencywalker – which check dependencies in Windows. It is vintage tool and it can’t solve properly all dependencies. Second tool is procmon, it tell us where Python is looking for libraries and why it cannot find it.

Copyright © 2019 Dawid Anioł Blog

Theme by Anders NorenUp ↑