ImageMagick, four point perspective distortion in a video
silveiraneto.net
silveiraneto.net
ffmpeg -i zelda_720p.mp4 -vf perspective=60:90:589:147:50:415:582:418 output.mp4
Edit: BTW on your picture it's not (50,145) but (50,415) for the bottom left corner.
Edit: if quvi supports still works, you can ffplay "https://www.youtube.com/watch?v=rMXD5DxbXog" -vf perspective=60:90:589:147:50:415:582:418 (otherwise something similar should be doable with youtube-dl)
Edit: you can also do better and enable the perspective only in the part where it matters. Typically with something like -vf "perspective=60:90:589:147:50:415:582:418:enable='not(between(t,0,5))'"
(GraphicsMagick is the ImageMagick of pictures, for me. IM has a few more features, but GM is more stable and usually much faster.)
$ port deps imagemagick Full Name: ImageMagick @6.8.9-8_0 Extract Dependencies: xz Build Dependencies: autoconf, automake, libtool Library Dependencies: bzip2, djvulibre, xz, jbigkit, jpeg, lcms2, libpng, tiff, webp, zlib, fftw-3, freetype, fontconfig, ghostscript, libiconv, libtool, openjpeg, openexr, expat, libxml2, pkgconfig Runtime Dependencies: urw-fonts
$ sudo deps graphicsmagick Full Name: GraphicsMagick @1.3.20_0+q8 Extract Dependencies: xz Library Dependencies: libxml2, bzip2, xz, zlib, libpng, tiff, freetype, libiconv, libtool, lcms2, jasper, jpeg
Perhaps it could be integrated into GM or something similar, and used as a back end for certain operations.
Even if the monitor moved alot (http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better...) it'd be fairly easy to write an algorithm to detect the four corners of the video. You basically want to throw some edge detection at it, and then look for anything that seem like corners.
Which, if you're a web dev like I am, seems scary at first, especially when you're (like me) lacking a CS education. However, as it turns out, understanding edge detection and Haar cascades (for feature detection, that was the problem I was solving) enough to be dangerous with OpenCV is surprisingly easy! I recently built some facial feature detection stuff in it that is in production right now, and it only took me a couple weeks :) So, have a play!
http://opencv-python-tutroals.readthedocs.org/en/latest/py_t...
or even
http://opencv-python-tutroals.readthedocs.org/en/latest/py_t...
Have no time to do the rectifying math on the components today but basically it would be some kind of inverse of this projective transformation:
http://franklinta.com/2014/09/08/computing-css-matrix3d-tran...
quick non-inverse transformation adapted from http://math.stackexchange.com/a/339033/70086
I had a demo for the 'inverse' transform also: http://codepen.io/fta/pen/LHonf
Here is the same thing except using the video from this post: http://codepen.io/fta/pen/JoGybG
1: http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/remap/...
http://www.pyimagesearch.com/2014/05/05/building-pokedex-pyt...
It's even written in Python.
https://gist.github.com/stschake/445aea35a3c9846573ad
I'm getting 50fps with the imshow, 100 without on an ooold Q6600. That said, remap is basically memory-bandwidth limited.
Step 1: Download the video with youtube-dl. This gives us zelda.mp4 (original video) and zelda.m4a (extracted audio, requires ffmpeg)
youtube-dl -x -k -o "zelda.%(ext)s" https://www.youtube.com/watch?v=rMXD5DxbXog
Step 2: Write the Avisynth script (in AvsPmod). Plugins used: LSMASHSource, Reformer, RemapFrames lwlibavvideosource("zelda.mp4")
deskewed = q2r(last,"lanczos",60,90,51,412,588,148,581,417)
normal = "[0 149] [1488 2063]" # frame ranges where to use original video
ReplaceFramesSimple(deskewed,last,mappings=normal)
Plugins used: LSMASHSource, Reformer, RemapFramesStep 3: Pipe it to x264 with avs2yuv (necessary under Wine and with 32-bit Avisynth & 64-bit x264) to encode the video.
avs2yuv zelda.avs -o - | x264 --preset slower --crf 16 -o zelda.mkv - --demuxer y4m
Step 4: Merge encoded video and original audio back together with mkvmerge from mkvtoolnix. You could use ffmpeg here as well, but I find mkvmerge much nicer for simple muxing like this. mkvmerge -o zelda_muxed.mkv zelda.mkv zelda.m4a
And with that, we're done. The whole process took about 20 minutes (of which ~13min was spent encoding the video) and a few hundred megabytes of space (since there's no need to have all the frames as individual image files several times over). Other benefits include having the video run at the original framerate of 29.970 (OP's video runs at 25.000 since he forgot to set the framerate when encoding the processed images), including the audio as well not having distorted picture when the TV isn't visible (which was simple enough to do with the ReplaceFramesSimple function from RemapFrames). You can see the end result here:https://www.youtube.com/watch?v=Jk_z4TiweHs
[1] http://www.avisynth.nl/users/vcmohan/Reformer/Reformer.html
ffmpeg -i zelda.mp4 -vf "perspective=60:90:589:147:50:415:582:418:enable='not(between(n,0,149)+between(n,1488,2063))'" -c:a copy -c:v libx264 zelda.mkv
Incidentally, this is a pretty big reason why I'd pick Avisynth over ffmpeg for video filtering any day of the week.
Note that FFmpeg doesn't require wine to work on Linux (or any other system), and it also handles here the audio, the encode, and the remuxing.
(Ah, and it doesn't need to download dll on random dubious sites or lost forum threads to make it usable)
And now imagine what those scripts would look like as an ffmpeg -vf command! That was basically the point - the -vf line is already pretty messy with just one range-applied command, and would become even more so if you started doing something more complicated. Avisynth on the other hand has actual scripts for the video processing, which scales to much more complex processing while still remaining accessible.
ffmpeg -vf might be good for doing one or two simple things to the whole video, but for anything more complex than that you really should use an actual video processing solution instead.
convert infile.mp4 %08d.png
Add -verbose in there if you want to see the progress as it goes.Unless you like Adware or what else ...
(JDownloader installs some crap Adware.)
Online, free.
http://board.jdownloader.org/showthread.php?t=44832&page=16
It seems to occur only using the web-installer, which is the one you're offically prompted at by the creators of JDownloader.
Well, I removed JDownloader and manually fixed the start page and search engines of firefox to remove the sweet-page stuff, but somehow my firefox is still screwed.
Questionable decision by the maker of JDownloader. I can't imagine that the money he gets for this is worth the damaged reputation.
Edit: I just ran an adware scanner. Besides the Sweet Page stuff, WindowsManagerProtect and Hold Page was installed. Several Registry Entries and Firefox setting were infected. Unbelievable ...
Also, a while ago I was working on making JDownloader less terrible (it should work like wget, UNIX philosophy and all). It's very labor-intensive though, but I may continue if enough people are interested (or help out): https://github.com/espes/jdget
Office Lens: http://research.microsoft.com/en-us/news/features/officelens... - imports to OneNote and does OCR
Post-it: https://itunes.apple.com/gb/app/post-it-plus/id920127738?mt=...
Drop the video in Virtuadub 1.10.4 and use it's buit-in "perspective" filter.
Using Blend mode and curves editor, you can only apply the filter to the parts of the video you want, so the part when gamepad is shown is not affected. (tutorial is here: https://www.youtube.com/watch?v=2MWoVY9mYbk)
b) We live in an amazing time for software and computing
Fantastic job!
http://uberhip.com/python/image-processing/opencv/2014/10/26...
youtube link, https://www.youtube.com/watch?v=BPijRAK2NHg
This second video better shows the effect with uncorrected and corrected video side by side. https://www.youtube.com/watch?v=7xQ0WDmTyVY
Thanks everybody.