Skip to content

Instantly share code, notes, and snippets.

View sgss's full-sized avatar

Shota Matsuda sgss

View GitHub Profile
class Application extends Observable
self = @initialize()
@static
stack: []
@property
delegate:
defaults: null
@property
processes:
attributes: readonly clones bindable
@sgss
sgss / gist:4702927
Last active December 12, 2015 02:58
// Derive dimensions of the capture device input.
AVCaptureInputPort *captureDeviceInputPort = nil;
for (AVCaptureInputPort *port in [captureDeviceInput ports]) {
if ([[port mediaType] isEqualToString:AVMediaTypeVideo]) {
captureDeviceInputPort = port;
break;
}
}
if (!captureDeviceInputPort) {
NSLog(@"Capture device input port of video media type was "
// Derive dimensions of the capture device input.
AVCaptureInputPort *captureDeviceInputPort = nil;
for (AVCaptureInputPort *port in [captureDeviceInput ports]) {
if ([[port mediaType] isEqualToString:AVMediaTypeVideo]) {
captureDeviceInputPort = port;
break;
}
}
if (!captureDeviceInputPort) {
CFXLogError(@"Capture device input port of video media type was "
- (CGPoint)pointForPointOfInterest:(CGPoint)pointOfInterest
{
CGPoint point;
if ([previewLayer respondsToSelector:
@selector(pointForCaptureDevicePointOfInterest:)]) {
// Use the native method if available (available on iOS 6 or above.)
point = [previewLayer pointForCaptureDevicePointOfInterest:pointOfInterest];
} else {
// Otherwise manually convert the point from point-of-interest coordinates
@sgss
sgss / gist:4702862
Last active December 12, 2015 02:58
template <typename I, typename O, typename Iterator>
inline void transform_image(
const cv::Mat_<I>& input,
cv::Mat_<O> *output,
Iterator iterator) {
if (input.size != output->size) {
DR_LOGE("Dimensions of input and output images must be identical.");
DR_LOGD("Skipping the rest.");
return;
}
@sgss
sgss / Info.plist
Created February 4, 2012 17:51
CoffeeScript BBEdit Language Module
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>11B26</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>CoffeeScript</string>
@sgss
sgss / TransparentizeGreenChannel.pbk
Created January 21, 2012 13:44
TransparentizeGreenChannel
<languageVersion: 1.0;>
kernel TransparentizeGreenChannel
< namespace : "Sgss";
vendor : "Matsuda Shota";
version : 1;
description : "Recovers transparency of grayscale image with key channel"; >
{
input image4 sourceImage;
output float4 destinationColor;
@sgss
sgss / length.coffee
Created January 14, 2012 13:12
Length representation class
class Length
self = @
@_pattern : /^\s*([+\-]?\s*[\d.]+(?:e[+\-]\d+)?)\s*([^\s]+)?\s*$/
@_units:
pixel : 'pixel'
millimeter : 'millimeter'