{"id":103,"date":"2011-09-27T20:11:23","date_gmt":"2011-09-27T20:11:23","guid":{"rendered":"http:\/\/classes.visitsteve.com\/hacking\/?p=103"},"modified":"2011-09-27T20:11:23","modified_gmt":"2011-09-27T20:11:23","slug":"slit-scan-modified","status":"publish","type":"post","link":"https:\/\/classes.visitsteve.com\/hacking\/slit-scan-modified\/","title":{"rendered":"Slit-Scan modified"},"content":{"rendered":"<p>We changed this so it will save at the end of every scan and restart again.<\/p>\n<pre>\/**\r\n* Simple Real-Time Slit-Scan Program.\r\n* By Golan Levin.\r\n*\r\n* This demonstration depends on the canvas height being equal\r\n* to the video capture height. If you would prefer otherwise,\r\n* consider using the image copy() function rather than the\r\n* direct pixel-accessing approach I have used here.\r\n*\r\n* Created December 2006.\r\n* Updated September 2011 by James Hale.\r\n*\/\r\nimport processing.video.*;\r\n\r\nCapture video;\r\n\r\nint videoSliceX;\r\nint drawPositionX;\r\n\r\nvoid setup() {\r\nsize(1000, 480, P2D);\r\n\r\n\/\/ Uses the default video input, see the reference if this causes an error\r\nvideo = new Capture(this, 1000, 480, 60);\r\n\r\nvideoSliceX = video.width \/ 2;\r\ndrawPositionX = width - 1;\r\nbackground(0);\r\n}\r\n\r\nvoid draw() {\r\nif (video.available()) {\r\nvideo.read();\r\nvideo.loadPixels();\r\n\r\n\/\/ Copy a column of pixels from the middle of the video\r\n\/\/ To a location moving slowly across the canvas.\r\nloadPixels();\r\nfor (int y = 0; y &lt; video.height; y++){\r\nint setPixelIndex = y*width + drawPositionX;\r\nint getPixelIndex = y*video.width + videoSliceX;\r\npixels[setPixelIndex] = video.pixels[getPixelIndex];\r\n}\r\nupdatePixels();\r\n\r\ndrawPositionX--;\r\n\r\n\/\/ Saves your image if pixels reach the end of the frame\r\nif (drawPositionX &lt; 0) {\r\nsaveFrame();\r\ndrawPositionX = width - 1; \/\/ not sure this works\r\n}\r\n\/\/ Takes another photo if you click the mouse.\r\nif(mousePressed) {\r\ndrawPositionX = width - 1;}\r\n}\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We changed this so it will save at the end of every scan and restart again. \/** * Simple Real-Time Slit-Scan Program. * By Golan Levin. * * This demonstration depends on the canvas height being equal * to the &hellip; <a href=\"https:\/\/classes.visitsteve.com\/hacking\/slit-scan-modified\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[17,18,19],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-class-examples","tag-golan-levin","tag-james-hale","tag-slit-scan"],"_links":{"self":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":0,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}