I’m happy to announce that the new edition of Mastering OpenCV is out!
You can get it on Amazon: Mastering OpenCV 3
It brings up most of the older OpenCV2 book projects to OpenCV3, including my Toy-SfM (or “Exploring SfM”) project.
A lot has happened in the OpenCV3 APIs with respect to Structure from Motion.
It got much easier!
The book chapter on SfM is a gentle introduction to the subject, that focuses on coding and the core concepts, while abstracting on the math.
Thanks for listening!
Roy
Man Camera2 APIs are hard to master…
I’ve scanned SO for a way to get touch-to-focus to work on Android and could not find a solution that works.
These were very partial, or provided only scaffold code which I couldn’t use:
- http://stackoverflow.com/questions/33151244/implement-tap-to-focus-in-camera2-api
- http://stackoverflow.com/questions/41649691/android-camera2-api-touch-to-focus-example
- http://stackoverflow.com/questions/34681903/android-camera2-touch-to-focus-implementation-cancelling-on-new-touch
- http://stackoverflow.com/questions/39850590/android-camera2-tap-to-focus
- https://www.reddit.com/r/androiddev/comments/3mpa90/camera2_touch_focus/
Finally I was able to do it by myself this way:
Enjoy
Roy
A friend asked me for a way to download all the PDFs from a page, and I made this simple script with Python and Mechanize. It’s very straightforward…
It does hack the user agent, which is not nice. So use at your discretion.
My first Thing on Thingiverse!
Just wanted to share the first Thing I uploaded to Thingiverse (which is a huge open-source collection of 3D-printable or otherwise fabricateable objects).
It’s a 1/4-20 (standard camera mount) holder for a smartphone using a rubber band.
I saw many designs that use screws to hold the phone in place, but I didn’t have such screws and I had many loose rubber bands. Also a rubber band allows the phone to snap in and out more easily.
It’s a very basic 3D design I did with FreeCAD, then made it on my FlashForge Creator Pro.
Enjoy
Roy
Hello,
I created a little video tutorial to model and render a folded piece of paper for a project I’m working on…
Here it is, enjoy!
Hello again!
After a long hiatus I’m back with an update. Recently I’ve been upgrading the Structure-from-Motion Toy Library (https://github.com/royshil/SfM-Toy-Library/) to OpenCV 3.x from OpenCV 2.4.x.
I spent an entire day getting OpenGL 4 to display data from a VAO with VBOs so I thought I’d share the results with you guys, save you some pain.
I’m using the excellent GL wrappers from Qt, and in particular QGLShaderProgram.
This is pretty straightforward, but the thing to remember is that OpenGL is looking for the vertices/other elements (color? tex coords?) to come from some bound GL buffer or from the host. So if your app is not working and nothing appears on screen, just make sure GL has a bound buffer and the shader locations match up and consistent (see the const int
I have on the class here).
I tried to set the capture format on a webcam from OpenCV’s cv2.VideoCapture and ran into a problem: it’s using the wrong IOCTL command.
So I used python-v4l2capture to get images from the device, which allows more control.
Here is the gist:
Enjoy!
Roy
I wasn’t able to find online a complete example on how to persist OpenCV matrices in Python (so really NumPy arrays) to YAML like what cv::FileStorage will give you.
So here’s a short snippet:
import numpy as np import yaml # A yaml constructor is for loading from a yaml node. # This is taken from: http://stackoverflow.com/a/15942429 def opencv_matrix_constructor(loader, node): mapping = loader.construct_mapping(node, deep=True) mat = np.array(mapping["data"]) mat.resize(mapping["rows"], mapping["cols"]) return mat yaml.add_constructor(u"tag:yaml.org,2002:opencv-matrix", opencv_matrix_constructor) # A yaml representer is for dumping structs into a yaml node. # So for an opencv_matrix type (to be compatible with c++'s FileStorage) we save the rows, cols, type and flattened-data def opencv_matrix_representer(dumper, mat): mapping = {'rows': mat.shape[0], 'cols': mat.shape[1], 'dt': 'd', 'data': mat.reshape(-1).tolist()} return dumper.represent_mapping(u"tag:yaml.org,2002:opencv-matrix", mapping) yaml.add_representer(np.ndarray, opencv_matrix_representer) #example with open('output.yaml', 'w') as f: f.write("%YAML:1.0") yaml.dump({"a matrix": np.zeros((10,10)), "another_one": np.zeros((2,4))}, f) # a matrix: !!opencv-matrix # cols: 10 # data: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, # 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, # 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, # 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, # 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, # 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, # 0.0, 0.0, 0.0, 0.0, 0.0] # dt: d # rows: 10 # another_one: !!opencv-matrix # cols: 4 # data: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # dt: d # rows: 2 with open('output.yaml', 'r') as f: print yaml.load(f) # {'a matrix': array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], # [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 'another_one': array([[ 0., 0., 0., 0.], # [ 0., 0., 0., 0.]])}
There you go
Sharing a small snippet on creating a loading spinner in a Tapestry 5.3+ Mixin, using spin.js.
It creates a convenient way to add spinners to your long-loading-times ajax zone updates, with all the code hidden away from the template .tml and page class object.
Sorry I can’t show a working example, that would entail running a Tapestry application server.
But it’s very straightforward, just grab the spin.min.js and the rest falls into place (it also depends on jQuery).