forked from ptomato/Beams
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: src/CameraImage.py
- Loading branch information
Showing
31 changed files
with
1,270 additions
and
1,662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_site | ||
awesome.css |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import threading | ||
import time | ||
|
||
|
||
class AcquisitionThread(threading.Thread): | ||
|
||
def __init__(self, camera, queue): | ||
super(AcquisitionThread, self).__init__() | ||
self.abort_flag = False | ||
self.camera = camera | ||
self.queue = queue | ||
|
||
def run(self): | ||
while not self.abort_flag: | ||
self.camera.query_frame() | ||
self.queue.put(self.camera.frame, block=False) | ||
time.sleep(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,59 @@ | ||
import numpy as N | ||
import matplotlib.colors | ||
from chaco.api import ColorMapper | ||
|
||
def rotate(x, y, angle): | ||
r, theta = N.sqrt(x ** 2 + y ** 2), N.arctan2(y, x) | ||
|
||
def _rotate(x, y, angle): | ||
r, theta = N.hypot(x, y), N.arctan2(y, x) | ||
theta += angle | ||
return r * (N.cos(theta), N.sin(theta)) | ||
|
||
def luminance_colormap(num_cycles=2, num_colors=256, reverse=False): | ||
''' | ||
Returns a Matplotlib color scale that cycles through the hues @num_cycles | ||
times, while maintaining monotonic luminance (i.e., if it is printed in | ||
black and white, then it will be perceptually equal to a linear grayscale. | ||
|
||
def isoluminant(rng, num_cycles=1, num_colors=256, reverse=False, **traits): | ||
""" | ||
Generator function for a Chaco color scale that cycles through the hues | ||
@num_cycles times, while maintaining monotonic luminance (i.e., if it is | ||
printed in black and white, then it will be perceptually equal to a linear | ||
grayscale. | ||
Ported from the Matlab(R) code from: McNames, J. (2006). An effective color | ||
scale for simultaneous color and gray-scale publications. IEEE Signal | ||
Processing Magazine 23(1), 82--87. | ||
''' | ||
""" | ||
|
||
# Triangular window function | ||
window = N.sqrt(3.0) / 8.0 * N.bartlett(num_colors) | ||
|
||
# Independent variable | ||
t = N.linspace(N.sqrt(3.0), 0.0, num_colors) | ||
|
||
# Initial values | ||
operand = (t - N.sqrt(3.0) / 2.0) * num_cycles * 2.0 * N.pi / N.sqrt(3.0) | ||
r0 = t | ||
g0 = window * N.cos(operand) | ||
b0 = window * N.sin(operand) | ||
|
||
# Convert RG to polar, rotate, and convert back | ||
r1, g1 = rotate(r0, g0, N.arcsin(1.0 / N.sqrt(3.0))) | ||
r1, g1 = _rotate(r0, g0, N.arcsin(1.0 / N.sqrt(3.0))) | ||
b1 = b0 | ||
|
||
# Convert RB to polar, rotate, and convert back | ||
r2, b2 = rotate(r1, b1, N.pi / 4.0) | ||
r2, b2 = _rotate(r1, b1, N.pi / 4.0) | ||
g2 = g1 | ||
|
||
# Ensure finite precision effects don't exceed unit cube boundaries | ||
r = r2.clip(0.0, 1.0) | ||
g = g2.clip(0.0, 1.0) | ||
b = b2.clip(0.0, 1.0) | ||
|
||
the_map = N.vstack((r, g, b)).T | ||
return matplotlib.colors.ListedColormap(the_map[::-1 if reverse else 1]) | ||
return ColorMapper.from_palette_array(the_map[::-1 if reverse else 1], | ||
range=rng, **traits) | ||
|
||
|
||
awesome = matplotlib.colors.ListedColormap(N.loadtxt('../data/awesomecolormap.csv', delimiter=',')) | ||
isoluminant = luminance_colormap() | ||
def awesome(rng, **traits): | ||
""" | ||
Generator function for a Chaco color scale that has low-intensity contrast. | ||
""" | ||
return ColorMapper.from_palette_array( | ||
N.loadtxt('../data/awesomecolormap.csv', delimiter=','), | ||
range=rng, **traits) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#coding: utf8 | ||
import numpy as N | ||
from traits.api import Button | ||
from traitsui.api import View, VGroup, Item | ||
from TransformPlugin import TransformPlugin | ||
|
||
|
||
class BackgroundSubtract(TransformPlugin): | ||
|
||
capture_background = Button() | ||
|
||
view = View( | ||
VGroup( | ||
Item('active'), | ||
Item('capture_background', show_label=False), | ||
label='Background Subtract', | ||
show_border=True)) | ||
|
||
def __init__(self, **traits): | ||
super(BackgroundSubtract, self).__init__(**traits) | ||
self._background_frame = None | ||
self._capture_next_frame = True | ||
|
||
def _process(self, frame): | ||
if self._capture_next_frame: | ||
self._background_frame = frame | ||
self._capture_next_frame = False | ||
temp = N.asfarray(frame) - self._background_frame | ||
if frame.dtype.kind == 'u': | ||
temp[temp < 0] = 0.0 | ||
return N.asarray(temp, dtype=frame.dtype) | ||
|
||
def _capture_background_fired(self): | ||
self._capture_next_frame = True |
Oops, something went wrong.