By: OpenSourcES
Re-posted from: https://opensourc.es/blog/2017-03-28-str8ts/index.html
Solving Str8ts puzzles using constraint programming and graph theor
Read more
By: OpenSourcES
Re-posted from: https://opensourc.es/blog/2017-03-28-str8ts/index.html
Solving Str8ts puzzles using constraint programming and graph theor
Read more
Recently I was using Julia to run ffprobe to get the length of a video file. The trouble was the ffprobe was dumping its output to stderr and I wanted to take that output and run it through grep. From a bash shell one would typically run:
ffprobe somefile.mkv 2>&1 |grep Duration
This would result in an output like
Duration: 00:04:44.94, start: 0.000000, bitrate: 128 kb/s
This works because we used 2>&1 to redirect stderr to stdout which would in be piped to grep.
If you were try to run this in Julia
julia> run(`ffprobe somefile.mkv 2>&1 |grep Duration`)
you will get errors. Julia does not like pipes | inside the backticks command (for very sensible reasons). Instead you should be using Julia’s pipeline command. Also the redirection 2>&1 will not work. So instead, the best thing to use is and instance of Pipe. This was not in the manual. I stumbled upon it in an issue discussion on GitHub. So a good why to do what I am after is to run.
julia> p=Pipe() Pipe(uninit => uninit, 0 bytes waiting) julia> run(pipeline(`ffprobe -i somefile.mkv`,stderr=p))
This would create a pipe object p that is then used to capture stderr after the execution of the command. Next we need to close the input end of the pipe.
julia> close(p.in)
Finally we can use the pipe with grep to filter the output.
julia> readstring(pipeline(p,`grep Duration`)) " Duration: 00:04:44.94, start: 0.000000, bitrate: 128 kb/s\n"
We can then do a little regex magic to get the duration we are after.
julia> matchall(r"(\d{2}:\d{2}:\d{2}.\d{2})",ans)[1] "00:04:44.94"
Re-posted from: http://learningjulia.com/2017/03/26/image-stitching-part-1.html
This is Part 1 of 2 in my posts about how to stitch two images together using Julia. It’s rough around the edges, since I’m learning how to do this myself. In Part 1 I talk about finding keypoints, descriptors, and matching two images together. Next time, I’ll talk about how to estimate the image transformation and how to actually do the stitching.