Hand gesture recognition in processing - processing

I'm trying to change an int variable using a hand gesture. I'm trying to turn on the webcam in processing and if you swing your hand to the left the value changes and when you swing your hand to the right the value changes again. Any ideas on how to go about this?

This question is pretty vague for StackOverflow. It's hard to answer general "how do I do this" type questions. It's much easier to answer specific "I tried X, expected Y, but got Z instead" type questions. That being said, I'll try to answer in a general sense.
Break your problem down into smaller steps.
Step 1: Can you write a simple sketch that simply displays the stream from a camera? The video library might be able to help you with that.
Step 2: Once you have that working, can you write code that tracks your hand? Try just drawing a dot on top of your hand. You might use OpenCV for this step.
Step 3: If you have code that can track your hand, then you can keep track of its position. You'll know when the position moves to the left or right, and you can take whatever action you want.
You might have to break these steps down into even smaller sub-steps. If you get stuck, then you can post an MCVE and a specific technical question, and we can go from there. Good luck.

Related

Ive been working on a "mario like" game engine in p5.js, im having some serious trouble with collision avoidance

By collision avoidance, i mean stopping the player from walking through something. Like in mario, he can't just walk through the blocks. I technically succeeded in making this, but it's very very bad. The player often gets stuck on the block once the player hits it, and i cant figure out how to fix it. I put all the code together on an online p5.js editor, Here
In the code i linked, I'm trying to get the player to not go through any of the terrain constructions i make, the one i have currently set up is a red square named 'block1'
Stack Overflow isn't really designed for general "how do I do this" type questions. It's for specific "I tried X, expected Y, but got Z instead" type questions. But I'll try to help in a general sense.
You need to take a step back and break your problem down into smaller steps and then take those steps on one at a time. Can you get a simple program working that just shows two hard-coded rectangles that change color if they're colliding? Get that working perfectly before moving on.
Shameless self-promotion: I wrote a tutorial on collision detection available here. That's for regular Processing, but everything should be basically the same for P5.js. Generally you probably want to use grid-based collision detection to figure out which cell your player is in, and then use rectangle-rectangle collision detection to actually check whether the player has hit a block.
If you're having trouble, please debug your code and try to narrow your problem down to a MCVE and ask a specific technical question. Good luck.

Detecting connections between objects in an image using evidence

I am trying trace lines in the following image. So my input image is like this:
So far, using deep learning, I am able to distinguish different shapes and I get following output and I have now type of shape and their position:
which seems to be pretty good to me. Also I am successful in finding lines between shapes like following, I want to use this as an evidence:
which detects more or less all the lines between each shape.
Question:
My aim is detect which shape/object is connected to which shape, and in which direction. For a while I am ignoring the directions (but any ideas to detect are welcome). But I am really stuck at how should I approach this problem of "tracing" lines.
At first I thought of an algorithm which "connects" two objects if we find enough "evidence", but in most images I have a tree like structure, there are three or more than three connections from one object (as between 4th and 5th level of input image), which makes it hard to go for that simple approach.
Did someone ever solve such a problem? I am just looking for an algorithm, programming language is not a problem but I am currently working in python. Any help would be really appreciated.

How to convert an image to animation?

I would like to apply some recursive mathematical operation on an arbitrary photo or image, which yield an interesting animation. I mean the first frame is the original picture and then the pixels are transformed in a way which leads to an interesting animation. For example a fractal animation or diffusion as particles or something similar. What approaches should I follow, what softwares to apply?
This is a very broad question, and it's hard to answer general "how do I do this" type questions. Stack Overflow is designed more for specific "I tried X, expected Y, but got Z instead" type questions. That being said, I'll try to answer in a general sense:
Step 1: Download Processing. You've tagged this with the processing tag, which is for questions about the Processing language. I can't tell whether that was on purpose, but it doesn't matter since Processing happens to be perfect for this task.
Step 2: Create a simple sketch that displays a single image, without any effects or animation. You need to break your problem down into smaller steps.
Step 3: Create a function that takes a PImage or a PGraphics and does the image manipulation for a single iteration of your algorithm. There are plenty of useful functions in the reference for manipulating the pixels in an image.
Step 4: Start with your initial image, and display that for X frames. Then pass that image into the function you created in step 3, and display the result of that for X frames. Then pass the update image back into your function, and repeat that process as many times as you want.
You could also generate every single frame ahead of time. Completely up to you.
There are a bunch of ways to do this, but those steps are the general outline. Please try something out, and break your problem down into smaller steps. Don't try to tackle your whole goal at one time. Instead, ask yourself: what's the smallest, simplest, easiest thing I know I have to do next?
If you get stuck, post an MCVE (note: not your whole sketch, just a small example that shows the problem you're stuck on) and a specific question, and we'll go from there. Good luck.

2D from 3D animation/graphics

I am sorry if it's a duplicate, but most of questions ask an opposite thing: 3D from 2D or sometimes they ask for a tool '2D from 3D' or: what to choose 2D or 3D. My case is different, I don't want any software/tool(s), I have already chosen the dimensions and I want 2D from 3D. Also I would like to give it a try writing myself, that's why I don't want any software.
I do understand that it will be a long term project, especially for such an amateur as me, but I find it interesting, that's why I want to attempt this task.
I will probably take 3D objects from the Xcode's Scene Kit and I would like to write a code, which will convert them into 2D.
I don't know what to start from and what to read. So any help will be very much appreciated. Also if there are some code examples (no matter which language) it will be awesome, because it's good to see how to assemble things/code etc.
//Also, please, have a look at the tags. I am not quite sure whether I choose them correctly. I will add Swift just in case. Because in my case it will be Swift, actually. However, the question is sort of general, so some people who won't use Swift may probably find prospective answers useful as well.

Extending CAShapeLayer with physics attributes (or is there a better solution)?

First disclamer, I'm a complete n00b in terms of iOS programming, but have over 15 years of other OOP experience.
I've done extensive search thus far on what I'm trying to accomplish, but have not come up with definitive answer.
I'm trying to create effect of drawing straight lines (simular in effect to fruit ninja cuting motion) where it would draw a line between point a (beginTouch) and b (endTouch) regardless of the angle.
I was able to achieve it pretty easily with use of CAShapeLayer. It also very usefull as it supports some animation options that I would like to be able to apply on end result line.
But what I also need is an ability to emulate physics behavior with resulting line shape, such as bouncing, possibly deforming the line to emulate stretching, and apply some sort of destruction animation (fading/breaking appart).
I'm not sure if the CAShapeLayer is the best option to achieve this effect and if it is where do I look next on extending it or combining it with something else.
I know this is not a specific code example type of question, but expert oppinion is appreciate.
Cheers
Alex

Resources