1
1
\ l arialBold .q
2
2
3
3
//Starts the camera
4
- startcamera : {[]
4
+ startcamera : {[width ; height ; pixelformat ]
5
5
//Start the driver which creates /dev/video0
6
- system "sudo modprobe bcm2835-v4l2" ;
6
+ system "modprobe bcm2835-v4l2" ;
7
7
//Start the camera
8
- system "sudo v4l2-ctl -v width=" , string [width ], ",height=" , string [height ], ",pixelformat=" , string [pixelformat ];
8
+ system "v4l2-ctl -v width=" , string [width ], ",height=" , string [height ], ",pixelformat=" , string [pixelformat ];
9
9
//Return a handle to the named pipe
10
10
hopen `:fifo:///dev/video0
11
11
};
@@ -21,8 +21,7 @@ snap:{[handle;size]
21
21
//Saves a ppm as a P6 encoded RGB image to disk
22
22
saveppm : {[filename ;pic ]
23
23
hsym [` $ "." sv string filename , `ppm ] 1:
24
- string [pic `encoding ], "\n " , string [pic `width ], " " , string [pic `height ], " " , string [pic `maxval ],
25
- "\n " , "c" $ pic [`data ];
24
+ string [pic `encoding ], "\n " , (" " sv string pic `width`height`maxval ), "\n " , "c" $ pic [`data ];
26
25
};
27
26
28
27
//Converts our image to greyscale
@@ -36,7 +35,7 @@ greyscale:{[pic]
36
35
//Saves pgm saves a P5 encoded greyscale image to disk
37
36
savepgm : {[filename ;pic ]
38
37
hsym [` $ "." sv string filename , `pgm ] 1:
39
- string [pic `encoding ], "\n " , string [ pic `width ] , " " , string [ pic `height ] , " " , string [ pic `maxval ] , "\n " ,
38
+ string [pic `encoding ], "\n " , ( " " sv string pic `width` height`maxval ) , "\n " ,
40
39
"c" $ pic `data ;
41
40
};
42
41
@@ -77,9 +76,8 @@ convolute:{[pic;kernel]
77
76
pic [`data ]: {[y ;kernel ;pic ]
78
77
(raze kernel )$ (raze (pic [`data ][y+til (count kernel )];
79
78
pic [`data ][(y+pic [`width ])+til (count kernel )];
80
- pic [`data ][(y+2 *pic [`width ])+til (count kernel )]))}
81
- [;kernel ;pic ] each
82
- til count pic [`data ];
79
+ pic [`data ][(y+2 *pic [`width ])+til (count kernel )]))
80
+ }[;kernel ;pic ] each til count pic [`data ];
83
81
pic
84
82
};
85
83
@@ -97,7 +95,8 @@ drawSingle:{
97
95
16 cut @ [x;where x=0 ;: ;0N ]
98
96
};
99
97
100
- draw : {raze each flip drawSingle each x
98
+ draw : {
99
+ raze each flip drawSingle each x
101
100
};
102
101
103
102
makePGM : {
0 commit comments