Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am doing a project where I am attempting to take out the green screen on a video on python but I do not know how to go about it.
Thank you!
well...I presume you have some kind of RGB image for each frame of video.
I.e an N by 3 array.
(You could use OpenCV to read each frame.)
So it is case of going through the image and locating all the green and replacing it with what you want.
E.g if the array is called arr then for each row, i, you would check whether arr[i] == [0,255,0].
But due to the nature of film, you aren't going to have a perfectly uniform 0,255,0 green. There will be shadows and other slight variations. Perhaps it wasn't even 0,255,0 to start out with.
So you are going to be looking at removing a range of colours. Now for each row we are searching for a range of colours and replacing them with your choice.
We now run the risk of identifying a colour for removal that we don't actually want removing....so how can we check for that...
We still probably won't get a perfect match around the edges (of the objects/people we want to keep in the image), so to make this less obvious, we might want to use a little bit of blur and so on and so forth.
Look at this video: https://www.youtube.com/watch?v=rIWoLCFvjME
Try to think about what logic code is required for each little step the user takes.
Also think about all the decision the user makes that are purely subjective. Obviously these would be nigh-on impossible to automate reliably. So now we are talking about some kind of interactive application that allows the user to select different actions based on their subjective choice.
And we quickly see why green screen is often removed manually, frame by frame using a powerful editing application like photoshop, after effects etc...
OpenCV (http://opencv-python-tutroals.readthedocs.org/en/latest/) will do a lot of the algorithms for you...there is almost enough there to build your interactive greenscreen removal software...
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm curious what a 3D implementation of conway's game of life would look like and thought it would make a fun side project. I'm trying to decide how to render the live/dead cells in 3D.
I'd like all the visuals to occur within an n * n * n cube, like a rubik's cube where all internal cells are also used. The only functionality I really need is the ability to change the colors of the "cells" after a certain time interval. Is there a framework or library that I could use to make the creation of the cube?
I created an implementation with Matplotlib using the "voxels" function but after about 150 boxes it gets too slow to even rotate, and seeing as it is going to be changing every hundredth of a second I dont anticipate mpl could handle it without some optimization that I'm as of yet unaware of. I've been trying to find more information about Python volume rendering techniques for this specific problem but i cant find the term for a "cube made out of cubes" so it has been difficult.
Thanks for any help.
The update rule for the game of life (in any dimension) is based on the value of the convolution of the board with a "counting" mask. (all ones in a little 3x3 (or 3x3x3 in your case) region. So, I would suggest using something like tensorflow (probably pytorch works fine too) and using tf.nn.conv3d to do that step fast. You probably need the GPU anyway to be able to rotate the thing quickly.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm looking to build a program in python allowing to overlay a video on a video such as 1 video as background and another one on the left top corner. The goal is then to automate it.
I've find methods to overlay images on videos using overlay and watermark but not to overlay videos. Then, I've find methods using FFMPEG but the goal is to make it through Python.
Would you guys have any ideas/resources on the way to 1)overlaying video on video with Python 2) automate the process on a second time ?
Thanks!
PS: I am using Python 3.7 with Windows 10.
One approach regarding this topic is very powerful and generalizable. Since the author of the question did not provide any example, I'll stay in the general case.
Consider a video as a series of pictures (which can be represented as numpy arrays. Once you read the whole series it in, you can do anything with it. Assume the background vid is called video1 and the one in the top left corner video2. Since a picture basically is a matrix you can create a new video with moviepy and in each timestep do the following:
create new numpy array video_combined
write current step of video1 into it
overwrite corresponding pixel values in top left corner with video2 (probably sliced or compressed, use opencv for example)
append this to new video
Alternatively (and a little bit easier), use the concatenation methods of moviepy (documentation link) for mixing videos together which seems to fully fulfill your needs.
Feel free to ask for more details to explain, if this doesn't fit your question already!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have images of the following type
etc..
What would be the easiest way of identifying what piece it is and if it is black or white? Do I need to use machine learning or is there an easier way?
It depends on your inputs. If all of your data looks like this (nice and clean, with contours being identical, just background and color changes), you could probably use some kind of pixel + color matching and you could be good to go.
You definitely know that deep learning and machine learning only approximate function (functions of pixels in this case), if you can find it (the function) without using those methods (with sensible amount of work), you always should.
And no, machine learning is not a silver bullet, you get an image and you throw it into convolutional neural networks black-box magic and you get your results, that's not the point.
Sorry but deep learning might be just an overkill to recognize a known set of images. Use template matching!
https://machinelearningmastery.com/using-opencv-python-and-template-matching-to-play-wheres-waldo/
You could do this using machine learning (plan or convolutional neural nets). This isn't that hard of a problem, but you have to do manual work of creating proper dataset with lots of pictures.
For example: For each piece you need to create picture with white/black field color. And you have to do different combinations, different chess piece sets vs. different table color schema. In order to make the system more robust to color schema you can try different color channels.
There are lots of questions, will the pictures you test always be in same resolution? If they aren't then you should also take that into consideration when creating dataset.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am trying to find out how to estimate position and orientation of an object using stereo camera images.
Assume a description of an object is given either by its edges and edge-relations, or points, or other features. The images are taken from above by a set of two cameras that have a fixed position relative to each other (like Microsoft Kinect gives you).
With Python's skimage toolkit I am able to recognise the similarites in the picture without telling if the searched object is in the images, but that is as far as I get.
What I want to do more is to segment the known object from the background and to be able to tell its position relatively to the cameras (e.g. by comparing its calculated position with the position of a known mark on the floor or something similar which I don't think will be too hard).
I know Python pretty well and have some experience in basic image processing. If this problem is already solved in OpenCV, I can work with that as well.
Thank you in advance for any help you give, either by naming keywords to improve my search, links, or by sharing your experience in this field!
To illustrate my problem: You have a bunch of same kind (shape+color) lego bricks laying in a chaotic manner, e.g. they are overlaying completely/partially or not at all and have an arbitrary orientation. The floor underneath is of the same color as the bricks. Cameras look straight down. Task is to find as many as bricks as possible and tell there location.
edit: added illustration
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm making an image recognition program in python 3, I've got as far as getting the name of the item if it isn't recognised, the path of the image to search, and I've used PIL to return the RGB values of each pixel. However: now that I've actually got to the pattern recognition, I have no idea how to attempt it. It's not a problem of errors in the code, or a lack of understanding to attempt this (this is the best way for me to learn programming languages), it's that I don't know what to program (the logic behind it, if you will).
Please note:
I'm not looking for any code, purely just an explanation of the logic behind it. (I know that this may not be the right place to ask, but since it was sort of a programming question, I decided it was ok)
This has been puzzling me and my programming friends for a few days now, so any help would be greatly appreciated.
You should give a try to OpenCV and Template Matching approach. There are more sophisticated algorithms such Feature Matching. It depends on the situation.
Try using OpenCV. An example algorithm can be:
Extract keypoints and features from your template using feature detector (ORB, Sift, Surf)
Do the same for the image
Compare keypoint descriptors (e.g. for ORB using BFMatcher)
Compare count of matched keypoints with your selected threshold
The logic behind this is actually quite simple. I googled a bit around and I found out it works like this:
You need to compare all pixels to the pixels in the pattern you need to compare, then just create a var which is set to False when a pixel doesn't match. As soon as this happens, the comparing function is stopped(You could use a while True: function with a break statement in it) and returnes False then. If it matches, there will be no set to 'False' and the variable of the beginning will stay True.
I hope I could give you an Idea of what to do.
Sincerely, heureka