3d Scanner Code
Status: Planning
Brought to you by:
kevinhall2010
File | Date | Author | Commit |
---|---|---|---|
SimpleTest | 2010-02-09 | kevinhall2010 | [r8] |
WebCamTest | 2010-02-09 | kevinhall2010 | [r3] |
usbFindSerialLib | 2010-02-09 | kevinhall2010 | [r3] |
README.rtf | 2010-02-09 | kevinhall2010 | [r6] updated instructions |
convert4bit_8bit_values.xls | 2010-02-02 | kevinhall2010 | [r2] added test code for webcam |
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf540 {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Monaco;} {\colortbl;\red255\green255\blue255;\red100\green56\blue32;\red196\green26\blue22;\red170\green13\blue145; \red92\green38\blue153;\red63\green110\blue116;\red38\green71\blue75;\red28\green0\blue207;\red46\green13\blue110; \red0\green116\blue0;} \margl1440\margr1440\vieww18780\viewh9480\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural \f0\fs24 \cf0 C328R - WebCam Test application.\ \ To Run the application, make sure you know which serial port your webcam\ is connected to. If you select the wrong serial port it will probably CRASH!!!!\ \ \ INSTRUCTIONS\ 1 )First choose your serial port from the combobox near the botton of the screen - if you forgot to plugin your usb cable you can click on the \b Find Serial \b0 button after you plug it in.\ 2) click on the Startup button\ \ 3) i) click on Take Picture\ or ii) click on the Continuous checkbox\ \ thats all there is to it. notice if you use JPEG Preview Picture then the colorsetting must be JPEG likewise if you use Preview Picture the colorsetting must NOT be JPEG.\ \ \ \ ADDING TO YOUR APPLICATION\ \ \ \ The application contains a framework which you can link into your application.\ It is located in the WebCam.app/Contents/Frameworks.\ It's called C328WebCam.framework. \ \ You are completely free to use it in any none commercial application. Hobby electronic applications are more then welcome to use it.\ \ You might find my blog of interest - then again you might not.\ http://kevinhall2010.blogspot.com/\ \ source code is available from sourceforge\ http://a3dscanner.sourceforge.net/\ https://sourceforge.net/projects/a3dscanner/files/\ \ To use the framework you need to add the framework to your program and somewhere add the header\ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \f1\fs20 \cf2 \CocoaLigature0 #import \cf3 <C328WebCam/WebCam.h>\ \ \ The API is simple (on purpose)\ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf0 - (\cf4 id\cf0 )init:(\cf5 NSString\cf0 *)path Baud:(\cf4 long\cf0 )baudrate;\ \ path is the unix path to the serial device for example /dev/cu.usbserial-FTSDFTHSB\ \ \ -(\cf4 bool\cf0 )Startup;\ \ call this function before anything else\ \ \ -(\cf4 void\cf0 )Close;\ \ when your done with the device close it \ \ \ \ \ -(\cf5 NSImage\cf0 *)GetPreview:(ImageSize)psize colorSetting:(\cf6 PColorSetting\cf0 )colorsetting;\ -(\cf5 NSImage\cf0 *)GetJPEGPreview:(ImageSize)psize colorSetting:(\cf6 PColorSetting\cf0 )colorsetting;\ -(\cf5 NSImage\cf0 *)GetSnapShot:(ImageSize)psize colorSetting:(\cf6 SColorSetting\cf0 )colorsetting;\ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf3 \ \ where ImageSize are:\ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf0 \cf7 S80x64\cf0 =\cf8 0x01\cf0 ,\ \cf7 S160x128\cf0 =\cf8 0x03\cf0 ,\ \cf7 S320x240\cf0 =\cf8 0x05\cf0 ,\ \cf7 S640x480\cf0 =\cf8 0x07\cf0 \ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf3 and PColorSetting are:\ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf0 \cf7 SGRAYSCALE2bit\cf0 =\cf8 0x01\cf0 ,\ \cf7 SGRAYSCALE4bit\cf0 =\cf8 0x02\cf0 ,\ \cf7 SGRAYSCALE8bit\cf0 =\cf8 0x03\cf0 ,\ \cf7 SCOLOR12bit\cf0 =\cf8 0x05\cf0 ,\ \cf7 SCOLOR16bit\cf0 =\cf8 0x06\cf0 ,\ \cf7 SCOLORJPEG\cf0 =\cf8 0x07\cf0 \ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf3 or SColorSetting are:\ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf0 \cf7 PGRAYSCALE2bit\cf0 =\cf8 0x01\cf0 ,\ \cf7 PGRAYSCALE4bit\cf0 =\cf8 0x02\cf0 ,\ \cf7 PGRAYSCALE8bit\cf0 =\cf8 0x03\cf0 ,\ \cf7 PCOLOR12bit\cf0 =\cf8 0x05\cf0 ,\ \cf7 PCOLOR16bit\cf0 =\cf8 0x06\cf0 \ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf3 \ \ \ /////// EXAMPLE //////////\ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf0 \ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf2 #import \cf3 <Cocoa/Cocoa.h>\cf2 \ #import \cf3 <C328WebCam/WebCam.h>\cf2 \ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf0 \ \cf4 int\cf0 main (\cf4 int\cf0 argc, \cf4 const\cf0 \cf4 char\cf0 * argv[]) \{\ \cf5 NSAutoreleasePool\cf0 * pool = [[\cf5 NSAutoreleasePool\cf0 \cf9 alloc\cf0 ] \cf9 init\cf0 ];\ \ \cf5 WebCam\cf0 *cam= [[WebCam alloc] init:\cf3 @"/dev/cu.usbserial-FTSDFTHSB"\cf0 Baud:\cf8 230400\cf0 ];\ [cam \cf9 Startup\cf0 ];\ \ \cf5 NSImage\cf0 *image=[cam \cf9 GetSnapShot\cf0 :\cf9 S640x480\cf0 \cf9 colorSetting\cf0 :\cf9 SCOLORJPEG\cf0 ];\ [cam \cf9 Close\cf0 ];\ \ \ \ \cf10 /* Save as JPEG image to disk*/\cf0 \ \cf5 NSData\cf0 *b3=[image \cf9 TIFFRepresentation\cf0 ] ;\ \cf5 NSBitmapImageRep\cf0 *b4 = [\cf5 NSBitmapImageRep\cf0 \cf9 imageRepWithData\cf0 :b3];\ \cf5 NSData\cf0 *b5=[b4 \cf9 representationUsingType\cf0 :\cf9 NSJPEGFileType\cf0 \cf9 properties\cf0 :\cf4 nil\cf0 ];\ [b5 \cf9 writeToFile\cf0 :\cf3 @"dump.jpg"\cf0 \cf9 atomically\cf0 :\cf4 YES\cf0 ];\ \ \ [pool \cf9 release\cf0 ];\ \cf4 return\cf0 \cf8 0\cf0 ;\ \}\ \pard\tx480\pardeftab480\ql\qnatural\pardirnatural \cf3 \ \ \ \ }