Results 1 to 2 of 2
  1. #1

    Integration of Blender with external Python Application

    Hello all,

    I have been studying a Machine Learning course that uses Python 3.5
    In that course I learnt how to process images including images captured by a webcam. So my code in Python tracks my eyes via the webcam and adds 1 to a counter every time I blink. Now I want to pass that information to a blend file running.
    It has a low poly humanoid face as my Avatar. This Avatar has shape_keys that make him blink.
    I have this signal from my python Machine Learning code say I as a person have blinked. How can we pass that signal to my Avatar and make him blink (i.e. manipulate the shape_keys). This completes an almost closed loop.

    This may be a critical requirement for our team that is building a wheelchair. The patient can talk to the wheel chair only via blinks. The wheelchair's on-board computer blinks back to say I understood what you want.

    I am a complete Blender-Nancy. I depend on you to guide me to make my avatar in blender blink. Please help with a step-by-step set of instructions.

    Thank you
    Last edited by shirishr; 14-May-17 at 18:07. Reason: Escalating



  2. #2
    Member kilon's Avatar
    Join Date
    Sep 2007
    Location
    Greece , Athens
    Posts
    1,707
    Blender python even though its embeded inside blender it offers full support for cpython. If you have code that must run as standalone then you will need to use IPC (Inter Process Communication) , IPC is short for "the way applications talk to each other" and there are many forms. I have played with two a) sockets and b) memory mapped files. Others are Pipes , DBUS, json etc.

    Sockets are what you use when you connect to internet on any network, it can connect anything at any distance. But they are not superfast so not good for super fast code. Expect 1 ms respond time locally and a bit more remotely.

    Memory mapped files is what your OS uses to load DLLs , they are extremely efficient because its a low level fuctionality of the OS that resides inside the OS kernel but they are strictly local meaning code that resides in the same memory. They have the advantage of sharing memory show you do not need to copy data around like sockets and they are extremely fast.

    If your code can run as a python library then its just a matter of making an addon and doing a import my_lib

    I wont provide you with a step by step process because there are literally billions of ways for doing this , this very basic functionality. Application and code that talks to each other or even different languages its not exception as you may thing its actually the rule . Even blender is a multi language project.

    Its up to you to modify your code to use these technologies as there is no golden rule. You will also find a ton of examples online. In the end Blender python is just plain python so do not expect anything really different.
    Last edited by kilon; 25-May-17 at 10:54.
    http://kilon.blogspot.com/ <--- This my blog, you will find things i make here like music, 3d and 2d graphics and python programming.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •