Difference between revisions of "Convex Mirror"

From Robert-Depot
Jump to: navigation, search
(OS X side)
(GRBL Settings)
 
(34 intermediate revisions by the same user not shown)
Line 1: Line 1:
Self Portrait in a Convex Mirror
+
[[Home | <<< back to Wiki Home]]
 +
 
 +
=Convex Mirror=
 +
 
 +
<blockquote>
 +
http://www.wga.hu/detail/p/parmigia/convex.jpg
 +
</blockquote>
 +
 
 +
<blockquote><poem>
 +
Francesco one day set himself
 +
To take his own portrait, looking at himself from that purpose
 +
In a convex mirror, such as is used by barbers . . .
 +
He accordingly caused a ball of wood to be made
 +
By a turner, and having divided it in half and
 +
Brought it to the size of the mirror, he set himself
 +
With great art to copy all that he saw in the glass,"
 +
Chiefly his reflection, of which the portrait
 +
Is the reflection, of which the portrait
 +
Is the reflection once removed.
 +
</poem>-John Ashbery, ''Self Portrait in a Convex Mirror''</blockquote>
 +
 
 +
<blockquote><poem>
 +
Besides this, in order to investigate the subtleties of art, he set himself one day to make his own portrait, looking at himself in a convex barber's mirror. And in doing this, perceiving the bizarre effects produced by the roundness of the mirror, which twists the beams of a ceiling into strange curves, and makes the doors and other parts of buildings recede in an extraordinary manner, the idea came to him to amuse himself by counterfeiting everything. Thereupon he had a ball of wood made by a turner, and, dividing it in half so as to make it the same in size and shape as the mirror, set to work to counterfeit on it with supreme art all that he saw in the glass, and particularly his own self, which he did with such lifelike reality as could not be imagined or believed.
 +
 
 +
Now everything that is near the mirror is magnified, and all that is at a distance is diminished, and thus he made the hand engaged in drawing somewhat large, as the mirror showed it, and so marvelous that it seemed to be his very own.
 +
</poem>-Vasari, ''Lives of the Artists''</blockquote>
 +
 
 +
http://farm4.staticflickr.com/3756/11534522475_fc236cf9ff.jpg
 +
 
 +
=GCODE=
 +
*Store home:
 +
<pre>
 +
(storing home)
 +
G90
 +
G92 X47.0 Y47.0
 +
M4
 +
</pre>
 +
=Tests=
 +
*draw a circle on blank image:
 +
**<code>convert ~/Pictures/convex_mirror_storefront/work/blank.jpg -stroke White -fill none -strokewidth 1 -draw "circle 932, 932, 2, 932" ~/Pictures/convex_mirror_storefront/work/just_circle.png</code>
 +
*convert to pnm:
 +
**<code>convert ~/Pictures/convex_mirror_storefront/work/just_circle.png ~/Pictures/convex_mirror_storefront/work/just_circle.pnm</code>
 +
*potrace to json:
 +
**<code>potrace ~/Pictures/convex_mirror_storefront/work/just_circle.pnm -W 30.0 -H 30.0 -M 4.0 -i -a 0 -b geojson -s -o ~/Pictures/convex_mirror_storefront/work/just_circle.json</code>
 +
*json to text:
 +
**<code>/json_to_txt.py ~/Pictures/convex_mirror_storefront/work/just_circle.json ~/Pictures/convex_mirror_storefront/work/just_circle.txt 0.1</code>
 +
*txt to nc:
 +
**<code>./render_gcode.py ~/Pictures/convex_mirror_storefront/work/just_circle.txt ~/Pictures/convex_mirror_storefront/work/just_circle.nc 5.0 5.0 1.0 100.0</code>
 +
*stream to plotter:
 +
**<code>./stream3.py ~/Pictures/convex_mirror_storefront/work/just_circle.nc /dev/tty.usbmodem1a1241</code>
 +
 
 
=Workflow=
 
=Workflow=
 
==RPi side==
 
==RPi side==
 +
*OSX:
 +
**<code>killall PTPCamera</code>
 
*take photo on raspberry pi:
 
*take photo on raspberry pi:
 
**<code>gphoto2 --capture-image-and-download --filename capt0004.jpg</code>
 
**<code>gphoto2 --capture-image-and-download --filename capt0004.jpg</code>
 
*send to laptop:
 
*send to laptop:
**<code>cp capt0004.jpg rtwomey@192.168.2.1:~/Pictures/raspi</code>
+
**<code>scp capt0004.jpg rtwomey@192.168.2.1:~/Pictures/raspi</code>
 
*USB reset device:
 
*USB reset device:
 
**<code>usbreset /dev/bus/usb/001/004</code>
 
**<code>usbreset /dev/bus/usb/001/004</code>
Line 12: Line 64:
 
*crop:
 
*crop:
 
**<code>convert ~/Pictures/raspi/frame0001.jpg -crop 1450x1450+779+275 +repage square0001.jpg</code>
 
**<code>convert ~/Pictures/raspi/frame0001.jpg -crop 1450x1450+779+275 +repage square0001.jpg</code>
 +
*bg subtract:
 +
**<code>python bgsubtract.py square0002.jpg square0008.jpg 20 2</code>
 
*edge detect:  
 
*edge detect:  
**<code>python edge.py square0001.jpg 32 103</code>
+
**<code>python edge.py square0001.jpg 20 255</code>
 
*convert to pnm:
 
*convert to pnm:
 
**<code>convert square0001_edge.png edge0001.pnm</code>
 
**<code>convert square0001_edge.png edge0001.pnm</code>
Line 19: Line 73:
 
**<code>potrace edge0001.pnm --tight -i -s -o frame0001.svg</code>
 
**<code>potrace edge0001.pnm --tight -i -s -o frame0001.svg</code>
 
*send to gcode machine:
 
*send to gcode machine:
**
+
Helper script:
 +
*<code>python process_image.py ~/Pictures/raspi/frame0024.jpg</code>
 +
*produces frame0024.svg
 +
 
 +
=Background Subtract=
 +
*subtract one image from background with given threshold and dilations:
 +
**<code>python bgsubtract.py background.jpg square.jpg 66 10</code>
 +
 
 +
==Processing from commandline==
 +
*install processing-java from tools menu in processing
 +
*run from command line:
 +
**<code>processing-java --sketch=/Users/rtwomey/processing/dm_xml/convexmirror_cmdline --output=tmp/convexmirror --run --force</code>
 +
**NOTE: all filenames in the app need full paths.
 +
*run workflow with processing from commandline:
 +
**<code>python bgprocessing.py ~/Pictures/raspi/frame0031.jpg</code>
 +
=draw a circle=
 +
*add a circle to background:
 +
**<code>convert background.jpg -stroke White -fill none -strokewidth 1 -draw 'circle 715,740 35,740' bgcircle.png
 +
</code>
 +
=make a circular matte=
 +
<syntaxhighlight lang="bash">
 +
convert -size 1864x1864 xc:black -fill white -draw 'circle 932, 932, 2, 932' circle_mask.gif
 +
</syntaxhighlight>
 +
*masking image with circle mask
 +
<syntaxhighlight lang="bash">
 +
convert circle.png circle_mask.gif -alpha Off -compose CopyOpacity -composite masked_circle.png
 +
</syntaxhighlight>
 +
*convert with
 +
<syntaxhighlight lang="bash">
 +
convert circle.png circle_mask.gif -alpha Off -compose CopyOpacity -composite -background black -alpha remove -alpha off masked_circle.png
 +
</syntaxhighlight>
 +
 
 +
=Error Image + Drawing Image=
 +
*compute new contours from error image. NOT DONE.
 +
*accumulate error image. NOT DONE.
 +
*accumulate drawing image. NOT DONE.
 +
=GRBL Settings=
 +
<syntaxhighlight lang="bash">
 +
$0=7.023 (x, step/mm)
 +
$1=7.023 (y, step/mm)
 +
$2=7.023 (z, step/mm)
 +
$3=10 (step pulse, usec)
 +
$4=20320.000 (default feed, mm/min)
 +
$5=65000.000 (default seek, mm/min)
 +
$6=56 (step port invert mask, int:00111000)
 +
$7=25 (step idle delay, msec)
 +
$8=900.000 (acceleration, mm/sec^2)
 +
$9=0.050 (junction deviation, mm)
 +
$10=0.100 (arc, mm/segment)
 +
$11=25 (n-arc correction, int)
 +
$12=3 (n-decimals, int)
 +
$13=1 (report inches, bool)
 +
$14=1 (auto start, bool)
 +
$15=0 (invert step enable, bool)
 +
$16=0 (hard limits, bool)
 +
$17=1 (homing cycle, bool)
 +
$18=0 (homing dir invert mask, int:00000000)
 +
$19=400.000 (homing feed, mm/min)
 +
$20=10000.000 (homing seek, mm/min)
 +
$21=100 (homing debounce, msec)
 +
$22=1.000 (homing pull-off, mm)
 +
</syntaxhighlight>
 +
=Contour simplification=
 +
*http://bost.ocks.org/mike/simplify/
 +
*http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
 +
*https://hydra.hull.ac.uk/resources/hull:8338

Latest revision as of 12:39, 4 June 2014

<<< back to Wiki Home

Convex Mirror

convex.jpg

Francesco one day set himself
To take his own portrait, looking at himself from that purpose
In a convex mirror, such as is used by barbers . . .
He accordingly caused a ball of wood to be made
By a turner, and having divided it in half and
Brought it to the size of the mirror, he set himself
With great art to copy all that he saw in the glass,"
Chiefly his reflection, of which the portrait
Is the reflection, of which the portrait
Is the reflection once removed.

-John Ashbery, Self Portrait in a Convex Mirror

Besides this, in order to investigate the subtleties of art, he set himself one day to make his own portrait, looking at himself in a convex barber's mirror. And in doing this, perceiving the bizarre effects produced by the roundness of the mirror, which twists the beams of a ceiling into strange curves, and makes the doors and other parts of buildings recede in an extraordinary manner, the idea came to him to amuse himself by counterfeiting everything. Thereupon he had a ball of wood made by a turner, and, dividing it in half so as to make it the same in size and shape as the mirror, set to work to counterfeit on it with supreme art all that he saw in the glass, and particularly his own self, which he did with such lifelike reality as could not be imagined or believed.

Now everything that is near the mirror is magnified, and all that is at a distance is diminished, and thus he made the hand engaged in drawing somewhat large, as the mirror showed it, and so marvelous that it seemed to be his very own.

-Vasari, Lives of the Artists

11534522475_fc236cf9ff.jpg

GCODE

  • Store home:
(storing home)
G90
G92 X47.0 Y47.0
M4

Tests

  • draw a circle on blank image:
    • convert ~/Pictures/convex_mirror_storefront/work/blank.jpg -stroke White -fill none -strokewidth 1 -draw "circle 932, 932, 2, 932" ~/Pictures/convex_mirror_storefront/work/just_circle.png
  • convert to pnm:
    • convert ~/Pictures/convex_mirror_storefront/work/just_circle.png ~/Pictures/convex_mirror_storefront/work/just_circle.pnm
  • potrace to json:
    • potrace ~/Pictures/convex_mirror_storefront/work/just_circle.pnm -W 30.0 -H 30.0 -M 4.0 -i -a 0 -b geojson -s -o ~/Pictures/convex_mirror_storefront/work/just_circle.json
  • json to text:
    • /json_to_txt.py ~/Pictures/convex_mirror_storefront/work/just_circle.json ~/Pictures/convex_mirror_storefront/work/just_circle.txt 0.1
  • txt to nc:
    • ./render_gcode.py ~/Pictures/convex_mirror_storefront/work/just_circle.txt ~/Pictures/convex_mirror_storefront/work/just_circle.nc 5.0 5.0 1.0 100.0
  • stream to plotter:
    • ./stream3.py ~/Pictures/convex_mirror_storefront/work/just_circle.nc /dev/tty.usbmodem1a1241

Workflow

RPi side

  • OSX:
    • killall PTPCamera
  • take photo on raspberry pi:
    • gphoto2 --capture-image-and-download --filename capt0004.jpg
  • send to laptop:
    • scp capt0004.jpg rtwomey@192.168.2.1:~/Pictures/raspi
  • USB reset device:
    • usbreset /dev/bus/usb/001/004

OS X side

  • crop:
    • convert ~/Pictures/raspi/frame0001.jpg -crop 1450x1450+779+275 +repage square0001.jpg
  • bg subtract:
    • python bgsubtract.py square0002.jpg square0008.jpg 20 2
  • edge detect:
    • python edge.py square0001.jpg 20 255
  • convert to pnm:
    • convert square0001_edge.png edge0001.pnm
  • vectorize:
    • potrace edge0001.pnm --tight -i -s -o frame0001.svg
  • send to gcode machine:

Helper script:

  • python process_image.py ~/Pictures/raspi/frame0024.jpg
  • produces frame0024.svg

Background Subtract

  • subtract one image from background with given threshold and dilations:
    • python bgsubtract.py background.jpg square.jpg 66 10

Processing from commandline

  • install processing-java from tools menu in processing
  • run from command line:
    • processing-java --sketch=/Users/rtwomey/processing/dm_xml/convexmirror_cmdline --output=tmp/convexmirror --run --force
    • NOTE: all filenames in the app need full paths.
  • run workflow with processing from commandline:
    • python bgprocessing.py ~/Pictures/raspi/frame0031.jpg

draw a circle

  • add a circle to background:
    • convert background.jpg -stroke White -fill none -strokewidth 1 -draw 'circle 715,740 35,740' bgcircle.png

make a circular matte

convert -size 1864x1864 xc:black -fill white -draw 'circle 932, 932, 2, 932' circle_mask.gif
  • masking image with circle mask
convert circle.png circle_mask.gif -alpha Off -compose CopyOpacity -composite masked_circle.png
  • convert with
convert circle.png circle_mask.gif -alpha Off -compose CopyOpacity -composite -background black -alpha remove -alpha off masked_circle.png

Error Image + Drawing Image

  • compute new contours from error image. NOT DONE.
  • accumulate error image. NOT DONE.
  • accumulate drawing image. NOT DONE.

GRBL Settings

$0=7.023 (x, step/mm)
$1=7.023 (y, step/mm)
$2=7.023 (z, step/mm)
$3=10 (step pulse, usec)
$4=20320.000 (default feed, mm/min)
$5=65000.000 (default seek, mm/min)
$6=56 (step port invert mask, int:00111000)
$7=25 (step idle delay, msec)
$8=900.000 (acceleration, mm/sec^2)
$9=0.050 (junction deviation, mm)
$10=0.100 (arc, mm/segment)
$11=25 (n-arc correction, int)
$12=3 (n-decimals, int)
$13=1 (report inches, bool)
$14=1 (auto start, bool)
$15=0 (invert step enable, bool)
$16=0 (hard limits, bool)
$17=1 (homing cycle, bool)
$18=0 (homing dir invert mask, int:00000000)
$19=400.000 (homing feed, mm/min)
$20=10000.000 (homing seek, mm/min)
$21=100 (homing debounce, msec)
$22=1.000 (homing pull-off, mm)

Contour simplification