Using Blender Python API to create 2D animations neural nets - python

I want to use Blender and Python to create simplified 2D animations of theories on how the computation of the human brain create consciousness. I have spent hours studying the Python-Blender API, and as of yet it is not clear how to do what I want to do. Before I spend the much larger amount of time necessary to learn both Blender and its Python API, I would like to know if, and how, it is possible to use Blender-Python to:
Create thousands of lines under program control, in the form of long thin parallelograms, and place the two parallel narrow edges of each such line on selected locations on a selected pair of parallel lines in the image,
change the color and z-level of nets of connectioned lines formed
out of such lines under python control, and
create, place, and change the coloring and z-level of some more
complicated lines, such as ones having one or more bends in them.
I want to do these things to represent various synchronized activations of neural sub-networks. I will be able to spend about a month or so learning and using the Blender and its Python API before the conference at which I want to display these animations, but before I start, I want to know if that is something that is realistically doable for a newbie in that time frame.
Thank you for any help you can give me. And if anybody would like to help me create such animations, I would happy to share the credit when they are placed on YouTube. You can contact me at ewporter#gmail.com

Related

Deep learning person detection with opencv

so I'm really new here. Currently working on a public art project where I need a little help with the programming because I'm kind off lost between codes.
First I'll give you a short description of the goal of the work and then state my problem.
I'm putting a webcam in the shopwindow of a gallery that is facing out on a public street. This webcam is connected to a tv screen that is facing outwards on the street so people see themselves being filmed (like cctv). Then if people stand still long enough for the camera the webcam makes an automatic screenshot what will be emailed to a site which hold a script for automatic attachment printing and the people from the street instantly come in to my gallery, on paper.
(and yes I have permission from the gallery to do this since it is slightly in the grey area of legality)
I come from a art background with interest in programming so this was all very very new for me and made it already quite far I think. I have a raspberry pi running with open cv and put a script on it for deep learning object detection (https://www.pyimagesearch.com/2017/09/18/real-time-object-detection-with-deep-learning-and-opencv/) < the link I used for that.
I also come across loads of pedestrian tracking but did not find a suitable code yet for a real time video stream.
So what I need from you guys, is a little help with how to make a timer in the script so that when people stand still long enough for the camera, it wil make the screenshot. It is a bit like reversed security cams script because they react on movement and I want it to react to no movement at all.
The automatic attachment printing part I got covered I think because there are a lot of scripts already on the internet.
If you have any tips or tricks.. please let me know.
Help a girl out!
Marije
There are a number of things you can try.
Is the camera faced towards a shopping street? In that case you could go for simple background subtraction. For each frame, apply some preprocessing (e.g. blurring, morpholoy operations), call findContours and compute the center of minEnclosingRect for each of these.
Another option is to use the inbuilt (and pretrained) HOG PeopleDetector. This is based on SVM (Support Vector Machines), which is another machine learning technique. For this to work efficiently you'd have to tune the parameters adequately. Since you're using a Pi you'd also need to consider the tradeoff between speed and accuracy. Using this technique, we'd be left with rectangles as well, so we can again compute the center.
For both techniques, you'd want to make sure that the center point doesn't fluctuate too much from frame to frame (that would mean the person is moving). For this you'd also want to take into account the framerate and understand that you can't guarantee person detection for every frame.
The caveat of the first technique, whilst having more explanatory power, would be that it'd detect ANYTHING that changes from frame to frame, that includes pets, bikes, cars (if on a public street) and so on. You could then consider filtering (e.g. by area, color).

Drawing Video Canvas In Python

I am not really sure where to start on a project. I designed a channel for the Roku using Brightscript over the past several months. I now need to design a similar project for a different device but using Python. I don't know a lot about Python, but from what I have read it looks fairly easy to learn. My question is in Brightscript I had to draw a canvas passing certain parameters like size, location and color. This essentially was the video player. In Python to create a video player, do you have to draw a canvas or the like? Brightscript comes with components like roVideoPlayer where the code passes needed information into this object. Are there modules for Python that can be imported that create the components?
Thanks for advice

Creating small scale application like Blender?

I have been thinking about my final year project topic and to be honest I want to create something GREAAAT like many others. I know C,C++,Java and Python (Python is getting quite popular these days).. I want to create a small-scale application like Blender (graphics rendering software) any tips for me? I prefer using OpenGL and it's shading language rather than Direct3D since it is open-source.
Tell me the stuffs I should know to pull this off and also if the combination of python and OpenGL a good choice for this application ?
I want to create a small-scale application like Blender (graphics rendering software) any tips for me?
Yes: Readjust your perception of software size/complexity. I occasionally contribute (TBH, it's been years since I submitted something substantial) to Blender and over the years it turned into a mighty suite. But the codebase is just as large.
A small object-viewer should definitely be possible. That's something you can build and add features upon, depending on how much time is left. I would do the visualization and movement in your scene first, then some basic interactions with your objects (translating, rotating, etc.). The final step would be adding tools (edit polygons, sculpt, etc.). If you are fit enough in C++, OpenGL and Software-Architecture on a larger scale it should be doable.

3D Animation of Fractals

I'm giving a presentation on Fractal Antennas (take a look at my previous threads) in November and I wanted to incorporate some animation to make my presentation easier to visualize the content I am referring to. Most of these animations would be relatively short, probably a minute long at the most. There are a few animations that would be fantastic to have:
Fractal Mountains - The animation continues to add new iterations that depict the complex features of a mountain range.
Fractal Koch Curve - The animation begins with an initiator (triangle) and adds new iterations. Either I slowly bring in the new fractal that has the next iteration, or I use the same model and users can see the iterations branching outward. I would prefer the latter technique.
Show a fractal. Increase the iteration, while keeping a constant length, to vindicate the fractal shrinking in size.
Show a fractal. Increase the iteration, while keeping a constant size, to vindicate the fractal is increasing it's total perimeter length.
Cell phone animation - show a cell phone that has multiple antennas popping out (they can be simple sketches of lines).
The trouble is, I've never done ANY animation before. In the programs I have already, they generate the coordinates of the fractals, if that can be of some use?
What is the best way to render those animations in the shortest time possible? The presentation is almost 6 weeks away! Blender might be an option, but I have no idea of how to go about this.
There are some great animations in this NOVA video that might give you an idea of what I'm after.
Thanks,
Austin
Personally, I've used VPython to create simple 3D graphics and animations. It's an easy to learn library that's freely available at http://vpython.org/. Since you have the coordinates already, it should be fairly easy to for you to incorporate that into the drawing.
Blender is a bit more complicated, but also incorporates python scripting if you want to spend the time to learn it.
Lastly, referencing some of the YouTube comments: if you use the video just cite it, or email and get permission. If you're not making money on this presentation, then odds are you're going to just fine using the videos.
The easiest would be to use matplotlib.mplot3d. The principle is the same as in the 2D animation described at http://www.scipy.org/Cookbook/Matplotlib/Animations but you will be using the 3D methods described in http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html.
I teach computer methods in physics and one of the activities is to create a Koch snowflake using Python and matplotlib. I also had a group of students create 3D fractals as their project using Python and Chaco (for interactivity) but using matplotlib instead is pretty straightforward. You can also try mayavi2 which is another 3D plotting library in Python.
If you want to create a movie then you need to save each frame as a graphics file then convert the files into movie using convert (ImageMagick), mencoder, ffmpeg or some other software.
I can probably provide some pseudocode/sample code but I'm too sleepy at the moment (it's 11:30pm from where I am).

How to create a picture with animated aspects programmatically

Background
I have been asked by a client to create a picture of the world which has animated arrows/rays that come from one part of the world to another.
The rays will be randomized, will represent a transaction, will fade out after they happen and will increase in frequency as time goes on. The rays will start in one country's boundary and end in another's. As each animated transaction happens a continuously updating sum of the amounts of all the transactions will be shown at the bottom of the image. The amounts of the individual transactions will be randomized. There will also be a year showing on the image that will increment every n seconds.
The randomization, summation and incrementing are not a problem for me, but I am at a loss as to how to approach the animation of the arrows/rays.
My question is what is the best way to do this? What frameworks/libraries are best suited for this job?
I am most fluent in python so python suggestions are most easy for me, but I am open to any elegant way to do this.
The client will present this as a slide in a presentation in a windows machine.
The client will present this as a slide in a presentation in a windows machine
I think this is the key to your answer. Before going to a 3d implementation and writing all the code in the world to create this feature, you need to look at the presentation software. Chances are, your options will boil down to two things:
Animated Gif
Custom Presentation Scripts
Obviously, an animated gif is not ideal due to the fact that it repeats when it is done rendering, and to make it last a long time would make a large gif.
Custom Presentation Scripts would probably be the other way to allow him to bring it up in a presentation without running any side-programs, or doing anything strange. I'm not sure which presentation application is the target, but this could be valuable information.
He sounds like he's more non-technical and requesting something he doesn't realize will be difficult. I think you should come up with some options, explain the difficulty in implementing them, and suggest another solution that falls into the 'bang for your buck' range.
If you are adventurous use OpenGL :)
You can draw bezier curves in 3d space on top of a textured plane (earth map), you can specify a thickness for them and you can draw a point (small cone) at the end. It's easy and it looks nice, problem is learning the basics of OpenGL if you haven't used it before but that would be fun and probably useful if your in to programing graphics.
You can use OpenGL from python either with pyopengl or pyglet.
If you make the animation this way you can capture it to an avi file (using camtasia or something similar) that can be put onto a presentation slide.
It depends largely on the effort you want to expend on this, but the basic outline of an easy way. Would be to load an image of an arrow, and use a drawing library to color and rotate it in the direction you want to point(or draw it using shapes/curves).
Finally to actually animate it interpolate between the coordinates based on time.
If its just for a presentation though, I would use Macromedia Flash, or a similar animation program.(would do the same as above but you don't need to program anything)

Categories