Processing: save color and depth images - macos

I just started working with Processing, because I need to get a sequence of images, color and depth. When I save does images while drawing, so for each image I get I save it. I have around 2fps. Is there a way to improve this?
My thought was to store the image in an array list. I thought there is a function setup() so there would be also a function shutdown() or something. So When i hit the Esc button or close the window which is getting cold. Like a decompiler. Where I can run a loop trough that lists and save them. But I don't find such a function.
I am working on a MacBook Air (2013)

If you use OpenNI/SimpleOpenNI I recommend a nicer option: use the the .oni format (which stores both depth and rgb streams). All you have to do is:
Record to an .oni file (fast/realtime)
Read the depth/color streams from the recorded .oni streams when you need to.
To record to an .oni file you've got two options:
Use the Examples > Contributed Libraries > SimpleOpenNI > OpenNI > RecorderPlay sketch to record (some explanations at the bottom of this answer)
Use OpenNI SDK's NiViewer utility which can also save/load .oni files. (You can easily install this using homebrew: brew install homebrew/science/openni2. The path in this case will be something like /usr/local/Cellar/openni2/2.2.0.33/share/openni2/tools/NiViewer)
Once you have your .oni file, you can easily read it/play it back at different rate and access depth/rgb streams to save to disk.
Regarding your existing program
The frame rate drops because in the same thread it's encoding and writing two images to disk per frame. You can improve this by:
saving to an uncompressed format (like tiff)
threading the image save operation (see the bottom of this answer for some ideas)

Related

Isolate OpenSCAD view

I occasionally do some work in OpenSCAD on Fiverr. Instead of sending 100 screenshots each day I would like to provide my clients with a live 3D preview of the object. But I need to do this without giving the source away (in the past I have been naive enough to get scammed this way).
I want my clients to be able look at the live 3D view without being able to see the source code.
For example, the following is a possible solution I was thinking of: hardcode the contents of the .scad file into a string inside an executable. Then start OpenSCAD with this string but only show the preview window, without the client being to look at the code.
You can, in fact, use the openscad.exe to generate a preview from a .scad file:
& "C:\Program Files\OpenSCAD\openscad.exe" --preview --camera=0,0,0,45,45,0,200 test.scad -o test.png
However, there are two problems with this method. 1. It only generates a PNG, I need my clients to be able to pan and zoom. 2. It needs a local file. I could generate a tmp file, open it with above command and then quickly delete the file.
Consider sending an STL file for them to look at. OpenSCAD can export to STL. There are two versions of STL: ascii and binary. OpenSCAD outputs the binary form. Your clients could view your STL file in something like viewstl.com.
Since they could 3d print from the STL you might consider adding some watermark type textures or features that would be difficult to remove. Another option would be to change some key dimensions enough to make it unusable but not so much that it looks bad.

I want to batch extract gps data (exif) then convert to address and save that text to a jpg

I have 1500 pictures that need the address where they were taken to be shown in the corner of the picture. I have the pictures geo-tagged.
I need help extracting the GPS data and converting that to an address.
Then getting that address and saving it into the picture in the bottom right corner. Can anyone help or point me in the right direction please?
You're going to need two things. First you need an application that will extract the EXIF data that you are interested in. You should be able to write this yourself as it is fairly simple to do. You will need the JPEG standard and just need enough of it to identify the markers; specifically the APPn markers. You are also going to need the EXIF and (possibly the) TIFF standards to figure out how to extract the data you need form the EXIF APPn marker.
Writing the information to the corner of the image is the tough part. There are probably command line applications that will allow you to do that already. If worst comes to worst, there are various language API's that will allow you to read a JPEG stream into a buffer; draw text to the buffer; then write the buffer back to a JPEG stream.
You will most likely need to use a programming language for this; I think Python would be suitable as it's easy to get started and has libraries needed for your task.
For example, in order to extract the location (coordinates) from the JPEG files you can use pyexiv2.
To transform those coordinates to addresses you need to use a geocoding service such as Google's Geocoding API - you can use their Python library directly or code your own using something like requests.
Now that you have the address data you can overlay that data onto images using Python's pillow library.
If you're looking for some code to get started let me shamelessly plug my own project called photomap; you can find code to read GPS information from images here: https://github.com/iticus/photomap/blob/master/handlers.py#L170

Any CLI tool to perform 3d texture mapping on the fly

I'm currently looking for a way to create a 'configurator' for a upholsters, similar to http://digitaldraping.com/configurator/furniture-sofa/?Cushions_Plain-Cream.png,Sofa_Stripe-Orange.png - you select your fabrics and they are 'drawn' on the sofa automatically.
Unfortunately, all the sites I've looked at seem to use pre-rendered transparent PNGs that are overlaid over each other to build up the full picture. The problem here is that we've figured out that we'd require over 120,000 different images to cover all models, fabrics etc!!
I've looked at a few 3d texture tools such as http://www.arahne.si/products/arah-drape.html, hoping that one of them would have a CLI option where you give it a pre-created wireframe, and a fabric to overlay, and it generates the required image on the fly, but so far everything seems to require real-time use of the GUI to use it.
So, is there a CLI tool that would do what I'm after, or can anyone suggest a way to manipulate the GUI automatically? (from a tech point of view, I'm comfortable with C, Bash, Python or PHP as a solution!)
Thanks!
ArahDrape 2.2 can now work from a command line without any GUI interface. You can also call ArahDrape as a C library. In this way, it can be used in a web server to create texture mapped images on the fly. The command line options are explained below.
ArahDrape 2.2j command line version, ©2015 Arahne
usage:
adCommand -o /tmp/outputImage.png -tN /home/user/texture.png [-hidemodel] [-divide 2] [-filterPNG] [-compressPNG 2] [-m /home/user/model.png] -owner name -activation 174b3cfb49e9 /home/user/project.drape
Input and output images can have png, .tif or .jpg extensions
-o output_image_file
-tN texture_image_file [N goes from 0 to 199]
-hidemodel will render all areas not in region as white
-divide N [N goes from 2 to 5] divide resulting image pixel size
-filterPNG if you do not filter it, rendering is faster
-compressPNG N [N goes from 0 to 9] lower number saves faster, but bigger files
-m model_image_file use this if you want to replace model image from the project; must have same pixel size
-owner owner_name pass the given owner name
-activation activation_code pass the given activation code
last parameter should be ArahDrape project file
All files should be entered with full path.
If you need spaces in filenames, use quotes "" around the filename.
If you provide only Owner name, without activation code, program returns registration code.
ArahDrape supports batch export.
Open ArahDrape project, click on texture you wish to replace, put all your texture in a directory, select from menu
Textures > Browse textures, and as you click the texture to load it, program will save the draped picture. If you have thousands of images, use keyboard shortcut = and program will automatically do them all.
Alpha channel transparency is supported in loading model images or textures, and saving the draped images, as long as you use PNG or TIFF.
Please check this video to see how
ArahDrape works in batch mode.
we (http://digitaldraping.com/) can do just what you are asking. We have two options creating images and rendering a meshed image on the fly. Just get in touch if you still need this solution.

Viewing progress of MovieWriter file for animation plots

I am doing simulations which can take several hours to finish and I am using matplotlib.animation's MovieWriter to handle the details of writing plots of the data to a movie file. I am simply following the example script, http://matplotlib.org/examples/animation/moviewriter.html.
Is it possible to open the movie while it is being written to? I would like to check the progress of the simulation? Maybe I need to use a video format which can operate on incomplete data stream.
I know an easy alternative is to use savefig simply save an image to file, but I was wondering if it is possible to "check" on the progress of the movie by making some simple changes.
When I try to open the movie while (on MacOS) I get an error basically saying that the format cannot be understood. Once fully written the file open with no problems.

Very large images in web browser

We would like to display very large (50mb plus) images in Internet Explorer. We would like to avoid compression as compression algorithms are not what CSI would have us believe that they are and the resulting files are too lossy.
As a result, we have come up with two options: Silverlight Deep Zoom or a Flash based solution (such as Zoomify). The issue is that both of these require conversion to a tiled output and/or conversion to a specific file type (Zoomify supports a single proprietary file type, PFF).
What we are wondering is if a solution exists which will allow us to view the image without a conversion before hand.
PS: I know that you can write an application to tile the images (as needed or after the load process) and output them; however, we would like to do this without chopping up the file.
The tiled approach really is the right way to do it.
Your users don't want to download a 50mb file before they can start viewing the image. You don't want to spend the bandwidth to serve 50 megs to every user who might only view a fraction of your image.
If you serve the whole file, users will eventually be able to load and view it, but it won't run smoothly for most of them.
There is no simple non-tiled way to serve just a portion of an image unless you want to use a server-side library like imagemagik or PIL to extract a specific subset of the image for each user. You probably don't want to do that because it will place a significant load on your server.
Alternatively, you might use something like google's map tool to provide zooming and scaling. Some comments on doing that are available here:
http://webtide.wordpress.com/2008/08/27/custom-google-maps/
Take a look at OpenSeadragon. To make a image can work with OpenSeadragon, you should generate a zoomable image format which mentioned here. Then follow starting guide here
The browser isn't going to smoothly load a 50 meg file; if you don't chop it up, there's no reasonable way to make it not lag.
If you dont want to tile, you could have the server open the file and render a screen sized view of the image for display in the browser at the particular zoom resolution requested. This way you arent sending 50 meg files across the line when someone only wants to get an overview of the image. That is, the browser requests a set of coordinates and an output size in pixels, the server opens the larger image and creates a smaller image that fits the desired view, and sends that back to the web browser.
As far as compression, you say its too lossy, but if thats what you are seeing you are probably using the wrong compression algorithm or setting for the type of image you have. The jpg format has quality settings to control lossiness, and PNG compression is lossless (the pixels you get after decompressing are the exact values you had prior to compression). So consider changing what you are using as compression, and dont just rely on the default settings in an image editor.

Resources