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).
I was looking for a way to get a fluid container live side-by-side with a custom width sidebar.
A custom width sidebar can’t be achieved with a Bootstrap column, and is a total mess to get right with floats if you then need a fluid container to get a grid system for the main section.
So, here’s one solution:
JSFiddle: https://jsfiddle.net/6sfog80k/
Sharing a small libjpeg snippet.
Some SO questions about it have only partial snippets:
- http://stackoverflow.com/questions/16390783/how-to-save-yuyv-raw-data-to-jpeg-using-libjpeg
- http://stackoverflow.com/questions/17029136/weird-image-while-trying-to-compress-yuv-image-to-jpeg-using-libjpeg
- http://stackoverflow.com/questions/19282402/how-to-compress-a-yuyv-image-into-a-jpeg
Enjoy!
Roy