SLProject  4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SENSAndroidCamera.cpp File Reference
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include "SENSAndroidCamera.h"
#include "SENSException.h"
#include <android/log.h>
#include <opencv2/opencv.hpp>
#include <Utils.h>
#include <HighResTimer.h>
#include "SENSAndroidCameraUtils.h"
#include "SENSUtils.h"
Include dependency graph for SENSAndroidCamera.cpp:

Go to the source code of this file.

Macros

#define LOG_NDKCAM_WARN(...)   Utils::log("SENSAndroidCamera", __VA_ARGS__);
 
#define LOG_NDKCAM_INFO(...)   Utils::log("SENSAndroidCamera", __VA_ARGS__);
 
#define LOG_NDKCAM_DEBUG(...)   Utils::log("SENSAndroidCamera", __VA_ARGS__);
 

Functions

void onCameraAvailable (void *ctx, const char *id)
 
void onCameraUnavailable (void *ctx, const char *id)
 
void onDeviceDisconnected (void *ctx, ACameraDevice *dev)
 
void onDeviceErrorChanges (void *ctx, ACameraDevice *dev, int err)
 
void onSessionClosed (void *ctx, ACameraCaptureSession *ses)
 
void onSessionReady (void *ctx, ACameraCaptureSession *ses)
 
void onSessionActive (void *ctx, ACameraCaptureSession *ses)
 
void onImageCallback (void *ctx, AImageReader *reader)
 
std::string getPrintableState (CaptureSessionState state)
 

Detailed Description

Authors
Michael Goettlicher, Luc Girod, Marcus Hudritsch
Date
Winter 2016
Remarks
Please use clangformat to format the code. See more code style on https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style

Definition in file SENSAndroidCamera.cpp.

Macro Definition Documentation

◆ LOG_NDKCAM_DEBUG

#define LOG_NDKCAM_DEBUG (   ...)    Utils::log("SENSAndroidCamera", __VA_ARGS__);

Definition at line 26 of file SENSAndroidCamera.cpp.

◆ LOG_NDKCAM_INFO

#define LOG_NDKCAM_INFO (   ...)    Utils::log("SENSAndroidCamera", __VA_ARGS__);

Definition at line 25 of file SENSAndroidCamera.cpp.

◆ LOG_NDKCAM_WARN

#define LOG_NDKCAM_WARN (   ...)    Utils::log("SENSAndroidCamera", __VA_ARGS__);

Definition at line 24 of file SENSAndroidCamera.cpp.

Function Documentation

◆ getPrintableState()

std::string getPrintableState ( CaptureSessionState  state)

Definition at line 606 of file SENSAndroidCamera.cpp.

607 {
608  if (state == CaptureSessionState::READY) // session is ready
609  return "READY";
610  else if (state == CaptureSessionState::ACTIVE)
611  return "ACTIVE";
612  else if (state == CaptureSessionState::CLOSED)
613  return "CLOSED";
614  else if (state == CaptureSessionState::MAX_STATE)
615  return "MAX_STATE";
616  else
617  return "UNKNOWN";
618 }

◆ onCameraAvailable()

void onCameraAvailable ( void ctx,
const char *  id 
)

Definition at line 30 of file SENSAndroidCamera.cpp.

31 {
32  reinterpret_cast<SENSAndroidCamera*>(ctx)->onCameraStatusChanged(id, true);
33 }

◆ onCameraUnavailable()

void onCameraUnavailable ( void ctx,
const char *  id 
)

Definition at line 34 of file SENSAndroidCamera.cpp.

35 {
36  reinterpret_cast<SENSAndroidCamera*>(ctx)->onCameraStatusChanged(id, false);
37 }

◆ onDeviceDisconnected()

void onDeviceDisconnected ( void ctx,
ACameraDevice *  dev 
)

Definition at line 42 of file SENSAndroidCamera.cpp.

43 {
44  reinterpret_cast<SENSAndroidCamera*>(ctx)->onDeviceDisconnected(dev);
45 }
void onDeviceDisconnected(void *ctx, ACameraDevice *dev)

◆ onDeviceErrorChanges()

void onDeviceErrorChanges ( void ctx,
ACameraDevice *  dev,
int  err 
)

Definition at line 47 of file SENSAndroidCamera.cpp.

48 {
49  reinterpret_cast<SENSAndroidCamera*>(ctx)->onDeviceError(dev, err);
50 }

◆ onImageCallback()

void onImageCallback ( void ctx,
AImageReader *  reader 
)

ImageReader listener: called by AImageReader for every frame captured We pass the event to ImageReader class, so it could do some housekeeping about the loaded queue. For example, we could keep a counter to track how many buffers are full and idle in the queue. If camera almost has no buffer to capture we could release ( skip ) some frames by AImageReader_getNextImage() and AImageReader_delete().

Definition at line 96 of file SENSAndroidCamera.cpp.

97 {
98  reinterpret_cast<SENSAndroidCamera*>(ctx)->imageCallback(reader);
99 }

◆ onSessionActive()

void onSessionActive ( void ctx,
ACameraCaptureSession *  ses 
)

Definition at line 67 of file SENSAndroidCamera.cpp.

68 {
69  LOG_NDKCAM_WARN("onSessionActive: CaptureSession state: session %p active", ses);
70  reinterpret_cast<SENSAndroidCamera*>(ctx)
71  ->onSessionState(ses, CaptureSessionState::ACTIVE);
72 }
#define LOG_NDKCAM_WARN(...)

◆ onSessionClosed()

void onSessionClosed ( void ctx,
ACameraCaptureSession *  ses 
)

Definition at line 53 of file SENSAndroidCamera.cpp.

54 {
55  LOG_NDKCAM_WARN("onSessionClosed: CaptureSession state: session %p closed", ses);
56  reinterpret_cast<SENSAndroidCamera*>(ctx)
57  ->onSessionState(ses, CaptureSessionState::CLOSED);
58 }

◆ onSessionReady()

void onSessionReady ( void ctx,
ACameraCaptureSession *  ses 
)

Definition at line 60 of file SENSAndroidCamera.cpp.

61 {
62  LOG_NDKCAM_WARN("onSessionReady: CaptureSession state: session %p ready", ses);
63  reinterpret_cast<SENSAndroidCamera*>(ctx)
64  ->onSessionState(ses, CaptureSessionState::READY);
65 }