Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion argus_camera/argus_camera.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from .cpp import *
from past.builtins import long

class ArgusCamera:

Expand All @@ -8,18 +9,26 @@ def __init__(self,
stream_resolution=(640, 480),
video_converter_resolution=(640, 480),
frame_duration_range=(long(1e9//30), long(1e9//30)),
exposure_time_range=(long(0),long(999999999)),
source_clip_rect=(0.0, 0.0, 1.0, 1.0),
gain_range=(0.,0.),
sensor_mode=0):

self.device_id = device_id

self.video_converter_resolution = video_converter_resolution

self.config = DEFAULT_DEVKIT_CONFIG()
self.config.setDeviceId(device_id)
self.config.setStreamResolution(stream_resolution)
self.config.setVideoConverterResolution(video_converter_resolution)
self.config.setFrameDurationRange(frame_duration_range)
self.config.setExposureTimeRange(exposure_time_range)
self.config.setGainRange(gain_range)
self.config.setSourceClipRect(source_clip_rect)
self.config.setSensorMode(sensor_mode)
self.config.setExposureCompensation(0)
self.config.setAeLock(True)
#self.config.setSensorMode(sensor_mode)
self.channels = 4

self.camera = IArgusCamera_createArgusCamera(self.config)
Expand All @@ -28,3 +37,7 @@ def read(self):
image = np.empty(list(self.video_converter_resolution)[::-1] + [self.channels], np.uint8)
self.camera.read(image.ctypes.data)
return image

def get_gain_range(self):
return self.config.getGainRange()

8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@
author_email='',
url='https://github.com/NVIDIA-Jetson/argus_camera',
packages=find_packages(),
ext_modules=[argus_camera_cpp]
ext_modules=[argus_camera_cpp],
install_requires=['future'],
entry_points={
'console_scripts': [
'example = argus_camera.examples.argus_camera_example:main'
]
}
)
34 changes: 34 additions & 0 deletions src/ArgusCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ ArgusCamera *ArgusCamera::createArgusCamera(const ArgusCameraConfig &config, int
return nullptr;
}
auto iSourceSettings = interface_cast<ISourceSettings>(iRequest->getSourceSettings());
auto iAutoControlSettings = interface_cast<IAutoControlSettings>(iRequest->getAutoControlSettings());
status = iSourceSettings->setSensorMode(sensorModes[camera->mConfig.getSensorMode()]);
if (Argus::STATUS_OK != status) {
if (info) {
Expand All @@ -179,6 +180,39 @@ ArgusCamera *ArgusCamera::createArgusCamera(const ArgusCameraConfig &config, int
return nullptr;
}

// 3. set exposure time
status = iSourceSettings->setExposureTimeRange(Argus::Range<uint64_t>(
camera->mConfig.getExposureTimeRange()[0],
camera->mConfig.getExposureTimeRange()[1]
));
if (Argus::STATUS_OK != status) {
if (info) {
*info = 20;
}
return nullptr;
}

// set exposure compensation
status = iAutoControlSettings->setExposureCompensation(float(
camera->mConfig.getExposureCompensation()));
if (Argus::STATUS_OK != status) {
if (info) {
*info = 21;
}
return nullptr;
}

// set ae lock
status = iAutoControlSettings->setAeLock(float(
camera->mConfig.getAeLock()));
if (Argus::STATUS_OK != status) {
if (info) {
*info = 24;
}
return nullptr;
}


// configure stream settings
auto iStreamSettings = interface_cast<IStreamSettings>(iRequest->getStreamSettings(camera->mStream.get()));
if (!iStreamSettings) {
Expand Down
23 changes: 23 additions & 0 deletions src/ArgusCamera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#define WIDTH_IDX 0
#define HEIGHT_IDX 1
#define ONE_SECOND_NANOS 1000000000
#define EXPOSURE_DEFAULT_LOW 0
#define EXPOSURE_DEFAULT_HIGH 9999999999999

class ArgusCameraConfig
{
Expand All @@ -27,6 +29,19 @@ class ArgusCameraConfig
void setFrameDurationRange(std::vector<uint64_t> frameDurationRange) { mFrameDurationRange = frameDurationRange; };
std::vector<uint64_t> getFrameDurationRange() { return mFrameDurationRange; };

void setGainRange(std::vector<float> gainRange) { mGainRange = gainRange; };
std::vector<float> getGainRange() { return mGainRange; };

void setExposureCompensation(float ExposureCompensation) { mExposureCompensation = ExposureCompensation; };
float getExposureCompensation() { return mExposureCompensation; };

void setAeLock(bool AeLock) { mAeLock = AeLock; };
bool getAeLock() { return mAeLock; };


void setExposureTimeRange(std::vector<uint64_t> exposureTimeRange) { mExposureTimeRange = exposureTimeRange; };
std::vector<uint64_t> getExposureTimeRange() { return mExposureTimeRange; };

void setSensorMode(uint32_t sensorMode) { mSensorMode = sensorMode; };
uint32_t getSensorMode() { return mSensorMode; };

Expand All @@ -35,6 +50,10 @@ class ArgusCameraConfig
std::vector<uint32_t> mStreamResolution;
std::vector<uint32_t> mVideoConverterResolution;
std::vector<uint64_t> mFrameDurationRange;
std::vector<uint64_t> mExposureTimeRange;
std::vector<float> mGainRange;
bool mAeLock;
float mExposureCompensation;
uint32_t mSensorMode;

std::vector<uint32_t> getOutputShape() {
Expand All @@ -53,7 +72,11 @@ ArgusCameraConfig DEFAULT_DEVKIT_CONFIG()
c.mStreamResolution = { 640, 480 };
c.mVideoConverterResolution = { 640, 480 };
c.mFrameDurationRange = { ONE_SECOND_NANOS / 30, ONE_SECOND_NANOS / 30 }; // 30fps
c.mExposureTimeRange = { EXPOSURE_DEFAULT_LOW,EXPOSURE_DEFAULT_HIGH };
c.mGainRange = {0.0, 300.0};
c.mSensorMode = 0;
c.mExposureCompensation = 0.;
c.mAeLock = false;
return c;
}

Expand Down