Showing posts with label GitHub. Show all posts
Showing posts with label GitHub. Show all posts

Monday, 10 March 2014

OpenGL Sandbox - New data and camera handling


I am working quite hard on the OpenGL Sandbox: you can find the repository on GitHub.


I've included some data of the Standord Scannin Repository's into the list of the available 3D models,
the "Stanford bunny" is rather important in the field of computer graphics and deserves a special mention: If you are intrested in it's history, here you can read something about it.


Furthermore, I have also included a very flexible logging system which grants me the possibility to know exactly what happening inside my program.

The other important thing that I've done is to create my own camera handling framework. The original idea was to implement an FPS like camera, although this set up turned out to be rather unconfortable.Therefore, I redesigned to work in the following way.


The camera points at a fixed point $\bar{C_l}$ in the space, and it can rotate on a sphere centered in $\bar{C_l}$ with a radius $C_r$.
You can move the camera on that sphere with a left-click and drag of your mouse. The radius $C_r$ can be modified with the mouse wheel.

You can also move the point $\bar{C_l}$ around and you might use your keyboard to do that. With W/S keys you can shift $\bar{C_l}$ on the Z-axis, A/S keys you can shift on the X-axis and with R/F on the Y-axis. I'm sorry to disappoint you but the R key does not involve any reload operation ;)

At the moment I'm striving to start to work on the shading, I need to add just a few modification in the application and then I can start working on it.

Saturday, 8 February 2014

Version control of OpenOffice/LibreOffice documents using git and Python

All my collegues in R&D department love Latex! Unfortunately it's not the same for commercial office people.

This is the reason why we write our manuals and documentations with LibreOffice. After the pain of a big revision on one of our manuals I've decided to introduce a version control also for the documentation as well.

Thus I wrote down a python script that generate automatically a Git-Friendly version of the ODT files.

Here's the link to the GitHub project and to a test project

If you launch the script with th -h option you will find how to use it:
odt_git_helper.py -h
usage: odt_git_helper.py [-h] [-v] [-c | -e] Directory ODT_File
Extract/Create an odt file in/from a directory.
positional arguments:
  Directory       target/destination directory
  ODT_File        target/destination odt file
optional arguments:
  -h, --help      show this help message and exit
  -v, --verbose   increase output verbosity
  -c, --compress  compress into an .odt file
  -e, --extract   extract odt file into a directory (default)

Monday, 20 January 2014

Single nm linewidth measurement

My girlfriend Marijke Scotuzzi is a PhD candidate at the Delft university of technology.

Her main goal is to deposit small structures in the sub-10nm range.

She deposited some lines next to each other and she needs to calculate the width of those lines: the figure below shows an example of those lines. You may noticethat it is affected by an heavy high frequency noise.
Furthermore the lines can hardly be distinguished from the back spots which lies on the surface around them.

I've tried to help her out by writing a C++ program to enhance the original image.
Luckily I can make some assumpions on the input image: the lines are always vertical an they cross the top and the bottom limit edge of the image.

I've developed the following algorithm:
  1. Apply a median blur to the image (optional) \[Image[j][i] = medianBlur(Image[j][i])\]
  2. Compute a per-column weight \[W[i] = \sum_{j=0}^J MedianImage[j][i]^2\]
  3. Apply a bilateral filter on vector W (optional) \[W[i] = bilateralFilter(W[i])\]
  4. Compute the enhanced image \[EnhancedImage[j][i] = Image[j][i]*\min((satO+W[i])*satM,255) \]

Here below some results are shown for a couple of images:

Input

Output

Median blur
Weights
Bilateral weights





Tuesday, 10 December 2013

Color fading with arduino

Yesterday evening I encountered this question on StackOverflow website.


In my opinion, the low quality of the original code is the main problem here. I suggested Tristan to use the Arduino Tinker Library and I wrote an example just for him.

#include <Vect3d.h>
#include <SerialLog.h>

Tinker::Vect3d<float> red(255,0,0);
Tinker::Vect3d<float> green(0,255,0);
Tinker::SerialLog serialLog;

void setup(){
  Serial.begin(9600);
  serialLog.display("Fade color example");  
  serialLog.endline();
}

void loop(){
  //fade factor computation
  const uint32_t t   = millis()%10000;
  const float cosArg = t/10000.*3.1415*2;
  const float fade   = abs(cos(cosArg));

  //Here's the color computation... as you can see is very easy to do!! :)
  Tinker::Vect3d<uint8_t> finalColor(red*fade + green*(1-fade));

  //We print the vect3d on the arduino serial port
  Tinker::LOG::displayVect3d(finalColor,&serialLog);
  serialLog.endline();
  delay(500);
}
This example will print the following output on the serial port:
Fade color example
V[255;0;0]
V[242;12;0]
V[206;48;0]
V[149;105;0]
V[78;176;0]
V[0;254;0]
V[79;175;0]
V[150;104;0]
V[206;48;0]
V[242;12;0]
V[254;0;0]
V[242;12;0]
V[205;49;0]
V[148;106;0]
V[77;177;0]
V[1;253;0]
V[80;174;0]
V[151;103;0]

If you want to fade multiple colors in one of your sketch you can simply use this code! :)

PS: Today I found this question on stack overflow: http://stackoverflow.com/questions/20482642/how-to-fade-between-two-vectors-by-value.

I'm really proud that someone is using the Arduino Tinker Library :)