SenbayKit 0.2.1

SenbayKit 0.2.1

Maintained by tetujin.

Depends on:
CocoaAsyncSocket>= 0
HaishinKit~> 0.10.5

SenbayKit 0.2.1

  • By
  • Yuuki Nishiyama


CI Status Version License Platform

SenbayKit is a development library for adding Senbay functions to your iOS app. In this library, three core libraries are included: Senbay Camera, Player, and Reader.


SenbayKit requires iOS10 or later. This library supports both Swift and Objective-C.


To run the example project, clone the repo, and run pod install from the Example directory first.


SenbayKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SenbayKit', :git => ''

How to use


  1. Setup Info.plist Please add following keys to Info.plist
  • NSCameraUsageDescription
  • NSMicrophoneUsageDescription
  • NSPhotoLibraryUsageDescription
  • NSLocationWhenInUseUsageDescription (only for SenbayCamera)
  1. Import SenbayKit into your source code
@import SenbayKit;

Senbay Camera

  1. Initialize SenbayCamera and set a preview view
// Objective-C //
SenbayCamera * camera = [[SenbayCamera alloc] initWithPreviewView: UI_IMAGE_VIEW];
camera.delegate = self;
[camera activate];
// Swift //
var camera = SenbayCamera.init(previewView: UI_IMAGE_VIEW)
camera.delegate = self;
  1. Fix a UIViewController orientation

SenbayCamera supports only LandscapeRigth. Please add following code to your UIViewController for fixing the UIViewController.

// Objective-C //
- (BOOL) shouldAutorotate {
    return NO;

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscapeRight;
// Swift //
override var shouldAutorotate: Bool {
    return  false

override var supportedInterfaceOrientations: UIInterfaceOrientationMask{
    return .landscapeRight
  1. Start and stop a video recording process

The recorded video is saved into automatically.

// Objective-C //
[camera startRecording];
[camera stopRecording];
// Swift //

  1. Activate sensors

You can embedded sensor data into an animated QR code on a video. Please activate required sensors from SenbaySensorManager class.

// Objective-C //
// Accelerometer: ACCX,ACCY,ACCZ
[camera.sensorManager.imu activateAccelerometer];
// Gyroscope:     PITC,ROLL,YAW
[camera.sensorManager.imu activateGyroscope];
// Magnetometer:  MAGX,MAGY,MAGZ
[camera.sensorManager.imu activateMagnetometer];

// GPS:         LONG,LATI,ALTI
[camera.sensorManager.location activateGPS];
// Compass:     HEAD
[camera.sensorManager.location activateCompass];
// Barometer:   AIRP
[camera.sensorManager.location activateBarometer];
// Speedometer: SPEE
[camera.sensorManager.location activateSpeedometer];

// Motion Activity:   MACT
[camera.sensorManager.motionActivity activate];

// Battery:           BATT
[camera.sensorManager.batteryLevel activate];
// Screen Brightness: BRIG
[camera.sensorManager.screenBrightness activate];

// Weather:        TEMP,WEAT,HUMI,WIND
[ activate];

// HR:             HTBT
[camera.sensorManager.ble activateHRM];
// BLE Tag:        BTAG
[camera.sensorManager.ble activateBLETag];
// Network Socket: NTAG
[camera.sensorManager.networkSocket activateUdpScoketWithPort:5000];
// Swift //
// Accelerometer: ACCX,ACCY,ACCZ
if let imu = camera.sensorManager.imu{

if let location = camera.sensorManager.location {

if let weather ={

If you want to use your original data format, please call -useFreeFormatData:, and set your data to the SenbaySensorManager.

// Objective-C //
[camera.sensorManager useFreeFormatData:YES];
[camera.sensorManager setFreeFormatData:@"YOUR DATA"];
// Swift //
camera.sensorManager.setFreeFormatData("YOUR DATA")
  1. Implement SenbayCameraDelegate on UIViewController

You can receive update events from SenbayCamera via SenbayCameraDelegate.

// Objective-C //
- (void) didUpdateFormattedRecordTime:(NSString *)recordTime;
- (void) didUpdateCurrentFPS:(int)currentFPS;
- (void) didUpdateQRCodeContent:(NSString *)qrcodeContent;
- (void) didUpdateVideoFrame:(UIImage *)videoFrame;
// Swift //
func didUpdateCurrentFPS(_ currentFPS: Int32)
func didUpdateFormattedRecordTime(_ recordTime: String!)
func didUpdateQRCodeContent(_ qrcodeContent: String!)
func didUpdateVideoFrame(_ videoFrame: UIImage!)
  1. (Option) Live Stream SenbayVideo via RTMP

RTMP (Real-Time Messaging Protocol) is one of a video, audio, and data streaming protocoal which is suppored on YouTube Live. You can stream SenbayVideo via RTMP by the following code.

/// start a broadcast via YouTube Live (Please relace [xxxx-xxxx-xxxx-xxxx] to your stream name. You can get the name from )
[camera startBroadcastWithStreamName:@"[xxxx-xxxx-xxxx-xxxx]" 
/// stop the broadcast
[camera finishBroadcast];
/// start a broadcast
/// stop the broadcast
  1. (Option) Change camera settings

You can cahnge camera settings (e.g., FPS, resolution, video export) using SenbayCameraConfig class on SenbayCamera before execute -activate method.

/// orverwride SenbayCameraConfig
SenbayCameraConfig * cameraConfig = [[SenbayCameraConfig alloc] initWithBuilderBlock:^(SenbayCameraConfig * _Nonnull config) {
  config.maxFPS = 30;
  config.videoSize = AVCaptureSessionPreset1280x720;
  config.isDebug = YES;
camera.config = cameraConfig;

/// or edit SenbayCameraConfig directly 
camera.config.maxFPS = 60;

/// NOTE: The settings should be modified before activate the camera instance
[camera activate];
let config = SenbayCameraConfig.init { (config) in
  config.isDebug = true
  config.maxFPS = 30
  config.videoSize = AVCaptureSession.Preset.hd1280x720
camera.config = cameraConfig;

/// or edit SenbayCameraConfig directly 
camera.config.maxFPS = 60;

/// NOTE: The settings should be modified before activate the camera instance

Senbay Player

  1. Initialize SenbayPlayer on UIViewController
// Objective-C //
SenbayPlaer * player = [[SenbayPlayer alloc] initWithView:UI_VIEW];
player.delegate = self;
[player setupPlayerWithLoadedAsset: ASSET];
// Swift //
player = SenbayPlayer.init(view: playerView)
player.delegate = self;
player.setupPlayer(withLoadedAsset: ASSET)
  1. Play and pause the SenbayPlayer
// Objective-C //
[player play];
[player pause];
// Swift //
  1. Implement SenbayPlayerDelegate on UIViewController

You can receive the decoded sensor data by implementing the delegate.

// Objective-C //
- (void)didDetectQRcode:(NSString *)qrcode;
- (void)didDecodeQRcode:(NSDictionary *)senbayData;
// Swift //
func didDetectQRcode(_ qrcode: String!)
func didDecodeQRcode(_ senbayData: [AnyHashable : Any]!)

Senbay Reader

  1. Initialize SenbayReader on UIViewController
// Objective-C //
SenbayReader * reader = [[SenbayReader alloc] init];
reader.delegate = self;
[reader startCameraReaderWithPreviewView: UI_VIEW];
// Swift //
var reader = SenbayReader()
reader.delegate = self;
reader.startCameraReader(withPreviewView: UI_VIEW)
  1. Receive detected and decoded data via SenbayReaderDelegate
// Objective-C //
- (void)didDetectQRcode:(NSString *)qrcode;
- (void)didDecodeQRcode:(NSDictionary *)senbayDat;
// Swift //
func didDetectQRcode(_ qrcode: String!)
func didDecodeQRcode(_ senbayData: [AnyHashable : Any]!)

Author and Contributors

SenbayKit is authord by Yuuki Nishiyama. In addition, Takuro Yonezawa, Denzil Ferreira, Anind K. Dey, Jin Nakazawa are deeply contributing this project. Please see more detail information on our website.

Related Links


Please cite these papers in your publications if it helps your research:

    author = {Nishiyama, Yuuki and Dey, Anind K. and Ferreira, Denzil and Yonezawa, Takuro and Nakazawa, Jin},
    title = {Senbay: A Platform for Instantly Capturing, Integrating, and Restreaming of Synchronized Multiple Sensor-data Stream},
    booktitle = {Proceedings of the 20th International Conference on Human-Computer Interaction with Mobile Devices and Services Adjunct},
    series = {MobileHCI '18},
    year = {2018},
    location = {Barcelona, Spain},
    publisher = {ACM},


SenbayKit is available under the Apache License, Version 2.0 license. See the LICENSE file for more info.