diff --git a/config.refindx b/config.refindx
index 99d1240..fb9bfd5 100644
--- a/config.refindx
+++ b/config.refindx
@@ -1,7 +1,7 @@
- analysis
+ analysing
1
640
@@ -15,52 +15,101 @@
- 3
- 3
- 3
- 3
- 5
- 5
- 5
- 5
- 3
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 30
- 30
- 30
- 30
- 30
- 30
- 40
- 10
- 30
+ 5
+ 5
+ 5
+ 5
+ 5
+ 5
+ 5
+ 5
+ 5
+
+ 0
+ -20
+ -400
+ -10
+ 0
+ 0
+
+
1000
4
2
- 4
+ 1
2
+ 0.5
+
+ 2
+ 1
+ 2
+ 0.5
+
1
500
1
+ 2
+ 2
-
- 3
- 1
+
+ 1
+ 500
1
-
+ 2
+ 2
+
+
+ 1
+ 500
+ 1
+ 2
+ 2
+
+
+ 1
+ 500
+ 1
+ 2
+ 2
+
+
+ 1
+ 500
+ 1
+ 2
+ 2
+
+
+ 4
+ 500
+ 2
+ 2
+
+
+ 1
+ 500
+ 1
+ 2
+ 2
+
-
- 51
- 25
-
-
\ No newline at end of file
diff --git a/dviid/hessian.cl b/dviid/hessian.cl
new file mode 100644
index 0000000..eb80d88
--- /dev/null
+++ b/dviid/hessian.cl
@@ -0,0 +1,372 @@
+/*
+ ~ copyright (c) 2011 dviid
+ ~ contact: dviid@labs.ciid.dk
+
+ + redistribution and use in source and binary forms, with or without
+ + modification, are permitted provided that the following conditions
+ + are met:
+ + > redistributions of source code must retain the above copyright
+ + notice, this list of conditions and the following disclaimer.
+ + > redistributions in binary form must reproduce the above copyright
+ + notice, this list of conditions and the following disclaimer in
+ + the documentation and/or other materials provided with the
+ + distribution.
+
+ + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ + SUCH DAMAGE.
+
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+const sampler_t smp = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
+
+const sampler_t smp_adrs = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
+
+
+float box_integral(read_only image2d_t src, int width, int height, int row, int col, int nbrrows, int nbrcols)
+{
+ float A = 0.0f;
+ float B = 0.0f;
+ float C = 0.0f;
+ float D = 0.0f;
+
+ int r0 = min(row, height) - 1;
+ int c0 = min(col, width) - 1;
+ int r1 = min(row + nbrrows, height) - 1;
+ int c1 = min(col + nbrcols, width) - 1;
+
+ A = read_imagef(src, smp, (int2)(c0, r0)).x;
+ B = read_imagef(src, smp, (int2)(c1, r0)).x;
+ C = read_imagef(src, smp, (int2)(c0, r1)).x;
+ D = read_imagef(src, smp, (int2)(c1, r1)).x;
+
+ return max(0.0f, A - B - C + D);
+
+}
+
+
+__kernel void hessian_det(
+ read_only image2d_t src,
+ int width,
+ int height,
+ write_only image2d_t determinant,
+ write_only image2d_t laplacians,
+ int layer_width,
+ int layer_height,
+ int step,
+ int filter)
+{
+ int l, w, b;
+ float Dxx, Dxy, Dyy, inverse;
+
+ int idx = get_global_id(0);
+ int idy = get_global_id(1);
+
+ w = filter;
+ l = w / 3;
+ b = (w - 1) / 2 + 1
+ inverse = 1.0f / (w * w);
+
+ int c = idx * step;
+ int r = idy * step;
+
+ if(r >= height || c >= width) return;
+
+ Dxx = box_integral(src, width, height, r - l + 1, c - b, 2 * l - 1, w) -
+ box_integral(src, width, height, r - l + 1, c - l / 2, 2 * l - 1, l) * 3;
+
+ Dxy = box_integral(src, width, height, r - l, c + 1, l, l) +
+ box_integral(src, width, height, r + 1, c - l, l, l) -
+ box_integral(src, width, height, r - 1, c - l, l, l) -
+ box_integral(src, widht, height, r + 1, c + 1, l, l);
+
+ DYY = box_integral(src, width, height, r - b, c - l + 1, w, 2 * l - 1) -
+ box_integral(src, width, height, r - l / 2, c - l + 1, l, 2 * l -1) * 3;
+
+ Dxx += inverse;
+ Dxy += inverse;
+ Dyy += inverse;
+
+ float4 det = {0.0f, 0.0f, 0.0f, 0.0f};
+ det.x = (Dxx * Dyy - 0.81f * Dxy * Dxy);
+
+ int4 lap = {0, 0, 0, 0};
+ lap.x = (Dxx + Dyy >= 0 ? 1 : 0);
+
+ write_imagef(determinant, (int2)(idx, idy), det);
+ write_imagef(laplacians, (int2)(idx, idy), lap);
+
+}
+
+int pop_laplacian(read_only image2d_t layer, int c, int r, int width)
+{
+ int lap;
+ lap = read_imagei(layer, smp_adrs, (int2)(c,r)).x;
+ return lap;
+}
+
+float pop_response(read_only image2d_t layer, int c, int r, int width, int scale)
+{
+ float resp;
+ resp = read_imagef(layer, smp_adrs, (int2)(c*scale, r*scale)).x;
+ return resp;
+}
+
+bool interpolate_extremum(
+ int r,
+ int c,
+ __global int* pts_cnt;
+ float2* pos,
+ float* det_scale
+ int* laplacian,
+ read_only image2d_t t,
+ int t_width,
+ int t_height,
+ int t_step,
+ read_only image2d_t m,
+ read_only image2d_t mlaplacian,
+ int m_width,
+ int m_height,
+ int m_filter,
+ read_only image2d_t b,
+ int b_width,
+ int b_height,
+ int b_filter
+ )
+{
+
+ // 3D derivatives
+
+ int mscale = (m_width / m_height);
+ int bscale = (b_width / b_height);
+
+ float Dx, Dy, Dz;
+
+ Dx = (pop_response(m, c+1, r, m_width, mscale) -
+ pop_response(m, c-1, r, m_width, mscale)) / 2.0f;
+ Dy = (pop_response(m, c, r+1, m_width, mscale) -
+ pop_response(m, c, r-1, m_width, mscale)) / 2.0f;
+
+ Dz = (pop_response(t, c, r, t_width, 1) -
+ pop_response(b, c, r, b_width, bscale)) / 2.0f;
+
+ // inverse hessian
+
+ float v, Dxx, Dyy, Dzz, Dxy, Dxz, Dyz;
+
+ v = pop_response(m, r, c, m_width, mscale);
+
+ Dxx = pop_response(m, c+1, r, m_width, mscale) +
+ pop_response(m, c-1, r, m_width, mscale) - 2.0f * v;
+
+ Dyy = pop_response(m, c, r+1, m_width, mscale) +
+ pop_response(m, c, r-1, m_width, mscale) - 2.0f * v;
+
+ Dxy = (pop_response(m, c+1, r+1, m_width, mscale) -
+ pop_response(m, c-1, r+1, m_width, mscale) -
+ pop_response(m, c+1, r-1, m_width, mscale) +
+ pop_response(m, c-1, r-1, m_width, mscale)) / 4.0f;
+
+ Dzz = pop_response(t, c, r, t_width, 1) -
+ pop_response(b, c, r, b_width, bscale) - 2.0f * v;
+
+ Dxz = (pop_response(t, c+1, r, t_width, 1) -
+ pop_response(t, c-1, r, t_width, 1) -
+ pop_response(b, c+1, r, b_width, bscale) +
+ pop_response(b, c-1, r, b_width, bscale)) / 4.0f;
+
+ Dyz = (pop_response(t, c, r+1, t_width, 1) -
+ pop_response(t, c, r-1, t_width, 1) -
+ pop_response(b, c, r+1, b_width, bscale) +
+ pop_response(b, c, r-1, b_width, bscale)) / 4.0f;
+
+ float det = Dxx * (Dyy*Dzz - Dyz*Dyz) -
+ Dxy * (Dxy*Dzz - Dyz*Dxz) +
+ Dxz * (Dxy*Dyz - Dyy*Dxz);
+
+ float invdet = 1.0f / det;
+
+ float invDxx = (Dyy*Dzz-Dyz*Dyz) * invdet;
+ float invDxy = -(Dxy*Dzz-Dyz*Dxz) * invdet;
+ float invDxz = (Dxy*Dyz-Dyy*Dxz) * invdet;
+ float invDyx = -(Dxy*Dzz-Dxz*Dyz) * invdet;
+ float invDyy = (Dxx*Dzz-Dxz*Dxz) * invdet;
+ float invDyz = -(Dxx*Dyz-Dxy*Dxz) * invdet;
+ float invDzx = (Dxy*Dyz-Dxz*Dyy) * invdet;
+ float invDzy = -(Dxx*Dyz-Dxz*Dxy) * invdet;
+ float invDzz = (Dxx*Dyy-Dxy*Dxy) * invdet;
+
+ // derivative * hessian
+
+ float xi = 0.0f, xr = 0.0f, xc = 0.0f;
+
+ xc -= invDxx * Dx;
+ xc -= invDxy * Dy;
+ xc -= invDxz * Dz;
+
+ xr -= invDyx * Dx;
+ xr -= invDyy * Dy;
+ xr -= invDyz * Dz;
+
+ xc -= invDzx * Dx;
+ xc -= invDzy * Dy;
+ xc -= invDzz * Dz;
+
+ // extremum??
+ if(fabs(xi) < 0.5f && fabs(xr) < 0.5f && fabs(xc) < 0.5f) {
+
+ int fstep = m_filter - b_filter;
+
+ (*pos).x = (float)((c + xc) * fstep);
+ (*pos).y = (float)((c + xr) * fstep);
+ *det_scale = (float)(0.1333f) * (m_filter + (xi * fstep));
+
+ int s = m_width / t_width;
+ *laplacian = pop_laplacian(mlaplacian, c * s, r * s, m_width);
+
+ return true;
+ }
+
+ return false;
+
+}
+
+bool is_extremum(
+ int r,
+ int c,
+ read_only image2d_t t,
+ int t_width,
+ int t_height,
+ int t_step,
+ int t_filter,
+ read_only image2d_t m,
+ int m_width,
+ int m_height,
+ read_only image2d_t b,
+ int b_width,
+ int b_height,
+ float tresh
+ )
+{
+ int border = (t_filter + 1) / (2 * t_step);
+
+ if(r <= border || r >= t_height - border || c <= border || c >= t_width - border) {
+ return false;
+ }
+
+ int mscale = m_width / t_width;
+
+ float candidate = pop_response(m, c, r, m_width, mscale);
+ if(candidate < tresh) {
+ return false;
+ }
+
+ // If any response in 3x3x3 is greater candidate not maximum
+ float localMax = getResponse(t, c-1, r-1, t_width, 1);
+ localMax = fmax(localMax, getResponse(t, c, r-1, t_width, 1));
+ localMax = fmax(localMax, getResponse(t, c+1, r-1, t_width, 1));
+ localMax = fmax(localMax, getResponse(t, c-1, r, t_width, 1));
+ localMax = fmax(localMax, getResponse(t, c, r, t_width, 1));
+ localMax = fmax(localMax, getResponse(t, c+1, r, t_width, 1));
+ localMax = fmax(localMax, getResponse(t, c-1, r+1, t_width, 1));
+ localMax = fmax(localMax, getResponse(t, c, r+1, t_width, 1));
+ localMax = fmax(localMax, getResponse(t, c+1, r+1, t_width, 1));
+
+ int bScale = b_width/t_width;
+
+ localMax = fmax(localMax, getResponse(b, c-1, r-1, b_width, bScale));
+ localMax = fmax(localMax, getResponse(b, c, r-1, b_width, bScale));
+ localMax = fmax(localMax, getResponse(b, c+1, r-1, b_width, bScale));
+ localMax = fmax(localMax, getResponse(b, c-1, r, b_width, bScale));
+ localMax = fmax(localMax, getResponse(b, c, r, b_width, bScale));
+ localMax = fmax(localMax, getResponse(b, c+1, r, b_width, bScale));
+ localMax = fmax(localMax, getResponse(b, c-1, r+1, b_width, bScale));
+ localMax = fmax(localMax, getResponse(b, c, r+1, b_width, bScale));
+ localMax = fmax(localMax, getResponse(b, c+1, r+1, b_width, bScale));
+
+ //int mScale = m_width/t_width;
+
+ localMax = fmax(localMax, getResponse(m, c-1, r-1, m_width, mScale));
+ localMax = fmax(localMax, getResponse(m, c, r-1, m_width, mScale));
+ localMax = fmax(localMax, getResponse(m, c+1, r-1, m_width, mScale));
+ localMax = fmax(localMax, getResponse(m, c-1, r, m_width, mScale));
+ // This is the candidate pixel
+ localMax = fmax(localMax, getResponse(m, c+1, r, m_width, mScale));
+ localMax = fmax(localMax, getResponse(m, c-1, r+1, m_width, mScale));
+ localMax = fmax(localMax, getResponse(m, c, r+1, m_width, mScale));
+ localMax = fmax(localMax, getResponse(m, c+1, r+1, m_width, mScale));
+
+ // If localMax > candidate, candidate is not the local maxima
+ if(localMax > candidate) {
+ return false;
+ }
+
+ return true;
+
+}
+
+__kernel void suppress_non_max(
+ read_only image2d_t tResponse,
+ int t_width,
+ int t_height,
+ int t_filter,
+ int t_step,
+ read_only image2d_t mResponse,
+ read_only image2d_t mLaplacian,
+ int m_width,
+ int m_height,
+ int m_filter,
+ read_only image2d_t bResponse,
+ int b_width;
+ int b_height,
+ int b_filter,
+ __global int* pts_cnt,
+ __global float2* pix_pos,
+ __global float* scale,
+ __global int* laplacian,
+ int max_pts,
+ float tresh
+ )
+{
+ int r = get_global_id(0);
+ int c = get_global_id(1);
+
+ float2 pixpos;
+ float s;
+ int lap;
+
+
+ if(is_extremum(r, c, tResponse, t_width, t_height, t_step, t_filter, mResponse, m_width, m_height, bResponse, b_width, b_height, tresh)) {
+
+ if(interpolate_extremum(r, c, pts_cnt, &pixpos, &s, &lap, tResponse, t_width, t_height, t_step, mResponse, mLaplacian, m_width, m_height, m_filter, bResponse, b_width, b_height, b_filter)) {
+
+ int indx = atom_add(&pts_cnt[0],1);
+ if(indx < max_pts) {
+ pix_pos[indx] = pix_pos;
+ scale[indx] = s;
+ laplacian[indx] = lap;
+ }
+
+ }
+
+ }
+}
+
+
+
+
+
+
+
+
+
diff --git a/dviid/imgproc.cl b/dviid/imgproc.cl
new file mode 100644
index 0000000..860b7d9
--- /dev/null
+++ b/dviid/imgproc.cl
@@ -0,0 +1,148 @@
+/*
+ ~ copyright (c) 2011 dviid
+ ~ contact: dviid@labs.ciid.dk
+
+ + redistribution and use in source and binary forms, with or without
+ + modification, are permitted provided that the following conditions
+ + are met:
+ + > redistributions of source code must retain the above copyright
+ + notice, this list of conditions and the following disclaimer.
+ + > redistributions in binary form must reproduce the above copyright
+ + notice, this list of conditions and the following disclaimer in
+ + the documentation and/or other materials provided with the
+ + distribution.
+
+ + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ + SUCH DAMAGE.
+
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+const sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
+
+__kernel void sobel(read_only image2d_t src, write_only image2d_t dst)
+{
+ int2 coords = (int2) (get_global_id(0), get_global_id(1));
+ int2 dx = (int2)(1,0);
+ int2 dy = (int2)(0,1);
+ float Gx, Gy, G, theta, p;
+
+ if(coords.x > get_image_width(dst) || coords.y > get_image_height(dst))
+ return;
+
+ p = read_imagef(src, smp, coords - dx + dy).s0;
+ Gx = p;
+ Gy = p;
+
+ p = read_imagef(src, smp, coords + dy).s0;
+ Gy += 2 * p;
+
+ p = read_imagef(src, smp, coords + dx + dy).s0;
+ Gx -= p;
+ Gy += p;
+
+ p = read_imagef(src, smp, coords - dx).s0;
+ Gx += 2 * p;
+
+ p = read_imagef(src, smp, coords + dx).s0;
+ Gx -= 2 * p;
+
+ p = read_imagef(src, smp, coords - dx - dy).s0;
+ Gx += p;
+ Gy -= p;
+
+ p = read_imagef(src, smp, coords - dy).s0;
+ Gy -= 2 * p;
+
+ p = read_imagef(src, smp, coords + dx - dy).s0;
+ Gx -= p;
+ Gy -= p;
+
+ G = sqrt(Gx * Gx + Gy * Gy);
+ theta = atan(Gx / Gy);
+
+ write_imagef(dst, coords, G);
+
+}
+
+__kernel void hgauss(read_only image2d_t src, write_only image2d_t dst,
+ global read_only float* weights, global float* offsets, const int nbr_weights)
+{
+ int2 coords = (int2) (get_global_id(0), get_global_id(1));
+ float2 src_coords = (float2) (get_global_id(0), get_global_id(1));
+ float4 pix = (float4)(0,0,0,0);
+
+ int i;
+ for(i = 0; i < nbr_weights; i++) {
+ pix += read_imagef(src, smp, src_coords + (float2) (offsets[i], 0.0f)) * weights[i];
+ }
+
+ write_imagef(dst, coords, clamp(pix, 0.0f, 1.0f));
+}
+
+__kernel void vgauss(read_only image2d_t src, write_only image2d_t dst,
+ global read_only float* weights, global float* offsets, const int nbr_weights)
+{
+ int2 coords = (int2) (get_global_id(0), get_global_id(1));
+ float2 src_coords = (float2) (get_global_id(0), get_global_id(1));
+ float4 pix = (float4)(0,0,0,0);
+
+ int i;
+ for(i = 0; i < nbr_weights; i++) {
+ pix += read_imagef(src, smp, src_coords + (float2) (0.0f, offsets[i])) * weights[i];
+ }
+
+ write_imagef(dst, coords, clamp(pix, 0.0f, 1.0f));
+}
+
+
+
+__kernel void grey(read_only image2d_t src, write_only image2d_t dst)
+{
+ int2 coords = (int2) (get_global_id(0), get_global_id(1));
+ float4 color = read_imagef(src, smp, coords);
+ float luminance = 0.3f * color.x + 0.59 * color.y + 0.11 * color.z;
+ color = (float4)(luminance, luminance, luminance, 1.0f);
+ write_imagef(dst, coords, color);
+}
+
+__kernel void brightness(read_only image2d_t src, write_only image2d_t dst)
+{
+ float max = 0;
+ int2 coords = (int2) (get_global_id(0), get_global_id(1));
+ float4 color = read_imagef(src, smp, coords);
+
+ max = color.x;
+ if(color.y > max) { max = color.y; }
+ if(color.z > max) { max = color.z; }
+
+ write_imagef(dst, coords, max);
+}
+
+__kernel void lightness(read_only image2d_t src, write_only image2d_t dst)
+{
+ float l = 0;
+ int2 coords = (int2) (get_global_id(0), get_global_id(1));
+ float4 color = read_imagef(src, smp, coords);
+
+ l = (color.x + color.y + color.z) / 3.0f;
+
+ write_imagef(dst, coords, l);
+}
+
+
+
+__kernel void hist()
+{
+
+}
\ No newline at end of file
diff --git a/dviid/intimg.cl b/dviid/intimg.cl
new file mode 100644
index 0000000..4dec642
--- /dev/null
+++ b/dviid/intimg.cl
@@ -0,0 +1,130 @@
+/*
+ ~ copyright (c) 2011 dviid
+ ~ contact: dviid@labs.ciid.dk
+
+ + redistribution and use in source and binary forms, with or without
+ + modification, are permitted provided that the following conditions
+ + are met:
+ + > redistributions of source code must retain the above copyright
+ + notice, this list of conditions and the following disclaimer.
+ + > redistributions in binary form must reproduce the above copyright
+ + notice, this list of conditions and the following disclaimer in
+ + the documentation and/or other materials provided with the
+ + distribution.
+
+ + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ + SUCH DAMAGE.
+
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#define WORK_G_SIZE 64
+#define HALF_WORK_G_SIZE (WORK_G_SIZE / 2)
+
+const sampler_t smp = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
+
+__kernel void scan(read_only image2d_t src, write_only image2d_t dst, int rows, int cols)
+{
+ __local float data0[WORK_G_SIZE + HALF_WORK_G_SIZE];
+ __local float data1[WORK_G_SIZE + HALF_WORK_G_SIZE];
+
+ int2 coords = (int2) (get_global_id(0), get_global_id(1));
+ int X = coords.x;
+ int Y = coords.x;
+
+ if(coords.x < HALF_WORK_G_SIZE) {
+ data0[coords.x] = 0.0f;
+ data1[coords.x] = 0.0f;
+ }
+
+ X += HALF_WORK_G_SIZE;
+ float max_val = 0.0f;
+
+ int it = cols / WORK_G_SIZE;
+ if(cols % WORK_G_SIZE != 0) {
+ it++;
+ }
+
+ for(int i = 0; i < it; i++) {
+
+ int col_offset = i * WORK_G_SIZE + coords.x;
+
+ data0[X] = read_imagef(src, smp, (int2)(col_offset, Y)).x;
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ // 1
+ data1[X] = data0[X] + data0[X-1];
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ // 2
+ data0[X] = data1[X] + data1[X-2];
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ // 4
+ data1[X] = data0[X] + data0[X-4];
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ // 8
+ data0[X] = data1[X] + data1[X-8];
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ // 16
+ data1[X] = data0[X] + data0[X-16];
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ // 32
+ data0[X] = data1[X] + data1[X-32];
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ if(col_offset < cols) {
+ write_imagef(dst, (int2)(col_offset, Y), (float4)(data0[X] + max_val, 0.0f, 0.0f, 0.0f));
+ }
+
+ max_val += data0[WORK_G_SIZE + HALF_WORK_G_SIZE - 1];
+ }
+
+}
+
+__kernel void transpose(read_only image2d_t src, write_only image2d_t dst, int rows, int cols)
+{
+
+ __local float buff[256];
+
+ int2 coords = (int2) (get_global_id(0), get_global_id(1));
+
+ int inX = coords.x;
+ int inY = coords.y;
+
+ int lX = coords.x;
+ int lY = coords.y;
+
+ int ginX = coords.x * 16 + lX;
+ int ginY = coords.y * 16 + lY;
+
+ buff[lY * 16 + lX] = read_imagef(src, smp, (int2)(ginX, ginY)).x;
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ int outRows = rows;
+ int outCols = cols;
+
+ int outX = inX;
+ int outY = inY;
+
+ int goutX = coords.x * 16 + lX;
+ int goutY = coords.y * 16 + lY;
+
+ if(goutX >= 0 && goutX < outCols && goutY >=0 && goutY < outRows) {
+ write_imagef(dst, (int2)(goutX, goutY), (float4)(buff[lX * 16 + lY], 0.0f, 0.0f, 0.0f));
+ }
+}
+
diff --git a/dviid/rfi.frag.glsl b/dviid/rfi.frag.glsl
new file mode 100644
index 0000000..14c1717
--- /dev/null
+++ b/dviid/rfi.frag.glsl
@@ -0,0 +1,18 @@
+#version 120
+
+uniform int algo;
+uniform sampler2DRect tex0;
+
+void main() {
+
+ if(algo == 4) {
+ vec4 color = texture2DRect(tex0, gl_TexCoord[0].st);
+ float luminance = 0.3f * color.x + 0.59 * color.y + 0.11 * color.z;
+ //gl_FragColor = vec4(luminance, luminance, luminance, 1.0f);
+ gl_FragColor = vec4(1.0f, 1.0f, 1.0f, 0.5f);
+ return;
+ }
+
+ gl_FragColor = texture2DRect(tex0, gl_TexCoord[0].st);
+
+}
diff --git a/dviid/rfi.geom.glsl b/dviid/rfi.geom.glsl
new file mode 100644
index 0000000..f6f8ec4
--- /dev/null
+++ b/dviid/rfi.geom.glsl
@@ -0,0 +1,127 @@
+#version 120
+#extension GL_EXT_geometry_shader4 : enable
+
+#define ALGO_1 1
+#define ALGO_2 2
+#define ALGO_3 3
+#define ALGO_4 4
+
+uniform int algo;
+uniform float scale;
+uniform sampler2DRect tex0;
+
+float max_color(vec3 rgb)
+{
+ float max = rgb.r;
+ if(rgb.g > max) { max = rgb.g; }
+ if(rgb.b > max) { max = rgb.b; }
+ return max;
+}
+
+float min_color(vec3 rgb)
+{
+ float min = rgb.r;
+ if(rgb.g < min) { min = rgb.g; }
+ if(rgb.b < min) { min = rgb.b; }
+ return min;
+}
+
+void hue(in vec4 color, out float h)
+{
+ float max = max_color(color.rgb);
+ float min = min_color(color.rgb);
+ if(max == min) { h = 0.f; }
+
+ float hueSixth;
+ if(color.r == max) {
+ hueSixth = (color.g - color.b) / (max - min);
+ if(hueSixth < 0.f)
+ hueSixth += 6.f;
+ } else if (color.g == max) {
+ hueSixth = 2.f + (color.b - color.r) / (max - min);
+ } else {
+ hueSixth = 4.f + (color.r - color.g) / (max - min);
+ }
+
+ h = 255.f * hueSixth / 6.f;
+}
+
+void saturation(in vec4 color, out float s)
+{
+ float max = max_color(color.rgb);
+ float min = min_color(color.rgb);
+ if(max == min) { s = 0.f; }
+
+ s = 255.f * (max - min) / max;
+}
+
+void brightness(in vec4 color, out float b)
+{
+ b = max_color(color.rgb);
+}
+
+void toHSB(in vec3 rgb, out vec3 hsb)
+{
+ float max = max_color(rgb);
+ float min = min_color(rgb);
+
+ if(max == min) {
+ hsb.x = 0.f;
+ hsb.y = 0.f;
+ hsb.z = 255.f * max;
+ return;
+ }
+
+ float hueSixth;
+ if(rgb.r == max) {
+ hueSixth = (rgb.g - rgb.b) / (max - min);
+ if(hueSixth < 0.f)
+ hueSixth += 6.f;
+ } else if (rgb.g == max) {
+ hueSixth = 2.f + (rgb.b - rgb.r) / (max - min);
+ } else {
+ hueSixth = 4.f + (rgb.r - rgb.g) / (max - min);
+ }
+ hsb.x = 255.f * hueSixth / 6.f;
+ hsb.y = 255.f * (max - min) / max;
+ hsb.z = max;
+}
+
+void main()
+{
+
+ if(algo == ALGO_4 && mod(gl_PositionIn[0].y, 2.f) != 0) return;
+
+ for (int i = 0; i < gl_VerticesIn; i++)
+ {
+
+ gl_Position = gl_PositionIn[i];
+
+ vec4 color0 = texture2DRect(tex0, gl_TexCoordIn[i][0].st);
+
+ float depth = 0.f;
+
+ if(algo == ALGO_1) {
+ brightness(color0, depth);
+ }
+ else if(algo == ALGO_2) {
+ hue(color0, depth);
+ }
+ else if(algo == ALGO_3) {
+ saturation(color0, depth);
+ }
+ else if(algo == ALGO_4) {
+ brightness(color0, depth);
+ }
+ else {
+ brightness(color0, depth);
+ }
+
+ gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Position.x, gl_Position.y, depth * scale, 1.0);
+ gl_TexCoord[0] = gl_TexCoordIn[i][0];
+
+ EmitVertex();
+ }
+
+
+}
diff --git a/dviid/rfi.vert.glsl b/dviid/rfi.vert.glsl
new file mode 100644
index 0000000..5de6428
--- /dev/null
+++ b/dviid/rfi.vert.glsl
@@ -0,0 +1,11 @@
+#version 120
+
+void main()
+{
+
+ gl_FrontColor = gl_Color;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_Position = gl_Vertex;
+
+
+}
diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp
index 9547215..df50b53 100644
--- a/example/RefractiveIndex.cpp
+++ b/example/RefractiveIndex.cpp
@@ -174,54 +174,31 @@ void RefractiveIndex::setup()
_analysisAdapator = NULL;
- //getting a warning from the OFlog that the pixels aren't allocated
- //void ofPixels::allocate(int w, int h, ofImageType type)
_pixels.allocate(_vid_w, _vid_h, OF_IMAGE_COLOR_ALPHA);
setup_shader_vbo();
- //TODO: whichever one of these is first - it always runs twice ?
+ //TODO: whichever one of these is first - it always runs twice ?
+ _analysisVector.push_back(new ShadowScapesAnalysis(V)); //1
+ _analysisVector.push_back(new ShadowScapesAnalysis(H)); //2
+ _analysisVector.push_back(new ShadowScapesAnalysis(D)); //3
+ _analysisVector.push_back(new RelaxRateAnalysis()); //4
+ _analysisVector.push_back(new IResponseAnalysis()); //5
+ _analysisVector.push_back(new ShapeFromShadingAnalysis()); //6
+ _analysisVector.push_back(new StrobeAnalysis()); //7
+ _analysisVector.push_back(new CamNoiseAnalysis()); //8
+ _analysisVector.push_back(new ColorSingleAnalysis()); //9
+ _analysisVector.push_back(new ColorMultiAnalysis()); //10
+ _analysisVector.push_back(new DiffNoiseAnalysis()); //11
- //_analysisVector.push_back(new ShadowScapesAnalysis(V));
- _analysisVector.push_back(new ShadowScapesAnalysis(H));
+ _currentAnalysis = NULL;
+ _state = ISTATE_UNDEF;
- /*
- _analysisVector.push_back(new ShadowScapesAnalysis(D));
-
- */
- _analysisVector.push_back(new RelaxRateAnalysis());
- /*
-
-
- _analysisVector.push_back(new IResponseAnalysis());
-
- _analysisVector.push_back(new ShapeFromShadingAnalysis());
-
- _analysisVector.push_back(new StrobeAnalysis());
-
- _analysisVector.push_back(new CamNoiseAnalysis());
-
- _analysisVector.push_back(new ColorSingleAnalysis());
-
- */
-
- _analysisVector.push_back(new ColorMultiAnalysis());
-
- //_analysisVector.push_back(new DiffNoiseAnalysis());
-
-
- _currentAnalysisIndx = 1;
- _state = ISTATE_TRANSITION;
-
- // to be idle at the beginning of the program (i.e. press keys to )
- //_currentAnalysis = NULL;
- //_state = ISTATE_UNDEF;
-
-
- ofSetEscapeQuitsApp(false);
+ // disbale ?
+ //ofSetEscapeQuitsApp(false);
}
@@ -333,28 +310,9 @@ void RefractiveIndex::stop_camera()
void RefractiveIndex::keyPressed (int key)
{
- std::stringstream out;
- out << (char)key;
- msg.append(out.str());
- if(msg.find("kcuf") != string::npos) {
- cout << "alright" << endl;
- exitApp();
- ::exit(1);
- }
-
-
- /*
if( key =='f')
ofToggleFullscreen();
- */
- /* TODO: complete the below... would be good to trigger the Analysis from keypresses if needed... */
- // currently this doesn't work... the save_cb's in the individual
- // tried to add a stop_analysis(); call but it blocks the whole programme
-
- // i.e.: ask david how to shut off the prior Analysis if it's not finished running from here?
-
- /*
if(key == 'x')
{
if(_currentAnalysis)
@@ -460,50 +418,7 @@ void RefractiveIndex::keyPressed (int key)
_currentAnalysisIndx = 10;
if(!_currentAnalysis)
_state = ISTATE_TRANSITION;
- }
- */
-
- /*
- TO DO: add a file dialog so we can save images to another hard drive...
- e.g.: http://dev.openframeworks.cc/pipermail/of-dev-openframeworks.cc/2011-April/003125.html
-
->> case 's':
->> doSave ^= true;
->> doLoad = false;
->> if(doSave) {
->> ofFileDialogResult r = ofSystemLoadDialog("Select path to save to", true);
->> if(r.bSuccess) {
->> saveCounter = 0;
->> savePath = r.getPath();
->> ofDirectory::createDirectory(savePath + "/color/");
->> ofDirectory::createDirectory(savePath + "/depth/");
->> printf("SAVE %s %s\n", r.getPath().c_str(), r.getName().c_str());
->> } else {
->> doSave = false;
->> }
->>
->> }
->> break;
->>
->> case 'l':
->> doLoad ^= true;
->> doSave = false;
->> if(doLoad) {
->> ofFileDialogResult r = ofSystemLoadDialog("Select path to load from", true);
->> if(r.bSuccess) {
->> loadCounter = 0;
->> loadPath = r.getPath();
->> ofDirectory dir;
->> loadMaxFiles = MAX(dir.listDir(loadPath + "/color"), dir.listDir(loadPath + "/depth"));
->> printf("LOAD %i %s %s\n", loadMaxFiles, r.getPath().c_str(), r.getName().c_str());
->> } else {
->> doLoad = false;
->> }
->>
->> }
->> break;
- */
-
+ }
}
diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp
index eed17c0..2a1269f 100644
--- a/src/AbstractAnalysis.cpp
+++ b/src/AbstractAnalysis.cpp
@@ -49,9 +49,9 @@ void AbstractAnalysis::do_synthesize() {
_state = STATE_ACQUIRING;
acquire();
if(_state == STATE_STOP) goto exit;
- //_state = STATE_SYNTHESISING;
- //synthesise();
- //if(_state == STATE_STOP) goto exit;
+ _state = STATE_SYNTHESISING;
+ synthesise();
+ if(_state == STATE_STOP) goto exit;
_state = STATE_DISPLAY_RESULTS;
displayresults();
}
@@ -108,7 +108,7 @@ void AbstractAnalysis::create_dir_allocate_images()
}
ofxFileHelper fileHelperAnalysis;
- //ofxFileHelper fileHelperSynthesis;
+ ofxFileHelper fileHelperSynthesis;
_whole_file_path_analysis = ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ;
@@ -131,7 +131,7 @@ void AbstractAnalysis::create_dir_allocate_images()
}
- /*
+
_whole_file_path_synthesis = SYNTHESIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime;
if(!fileHelperSynthesis.doesDirectoryExist(_whole_file_path_synthesis)){
@@ -149,7 +149,7 @@ void AbstractAnalysis::create_dir_allocate_images()
fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime);
}
- */
+
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp
index e59b364..691b626 100755
--- a/src/CamNoiseAnalysis.cpp
+++ b/src/CamNoiseAnalysis.cpp
@@ -13,6 +13,13 @@ using Poco::Thread;
#define NUMBER_RUNS 1
#define ACQUIRE_TIME 20
+const int algo_default = 1;
+const int scale_default = 500;
+const int draw_style_default = 3;
+const int line_width_default = 0.5f;
+const float point_size_default = 0.5f;
+
+
void CamNoiseAnalysis::setup(int camWidth, int camHeight)
{
AbstractAnalysis::setup(camWidth, camHeight);
@@ -47,52 +54,25 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight)
_show_image = false;
_image_shown = false;
+
image1.clear();
image2.clear();
- image3.clear();
- image4.clear();
- image5.clear();
-
+
// images use for drawing the synthesized files to the screen ///
image1.setUseTexture(false); // the non texture image that is needed to first load the image
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
-
- // images used for re-loading and saving out the synthesized files ///
- image3.setUseTexture(false);
- image4.setUseTexture(false);
- image5.setUseTexture(false);
-
+
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
-
- //cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
- //cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
-
- // clear() apparently fixes the "OF_WARNING: in allocate, reallocating a ofxCvImage"
- // that we're getting in OSX/Windows and is maybe crashing Windows
- // http://forum.openframeworks.cc/index.php?topic=1867.0
- cvColorImage1.clear();
- cvGrayImage1.clear();
- cvGrayDiff1.clear();
-
- cvColorImage2.clear();
- cvGrayImage2.clear();
- cvGrayDiff2.clear();
-
- cvConvertorImage.clear();
-
- cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
+
+
+ ////---------
+
+ algo = RefractiveIndex::XML.getValue("config:algorithms:camnoise:algo", algo_default);
+ scale = RefractiveIndex::XML.getValue("config:algorithms:camnoise:scale", scale_default);
+ draw_style = RefractiveIndex::XML.getValue("config:algorithms:camnoise:draw_style", draw_style_default);
+ line_width = RefractiveIndex::XML.getValue("config:algorithms:camnoise:line_width", line_width_default);
+ point_size = RefractiveIndex::XML.getValue("config:algorithms:camnoise:point_size", point_size_default);
}
@@ -127,112 +107,51 @@ void CamNoiseAnalysis::acquire()
void CamNoiseAnalysis::synthesise()
{
- //cout << "CamNoiseAnalysis::saving synthesis...\n";
- if(_state == STATE_STOP) return;
+ // we don't need to synthesise
+ return;
+
+ /*
+
+ //cout << "IResponseAnalysis::saving synthesis...\n";
+ if(_state == STATE_STOP) return;
+
+ _RUN_DONE = false;
+
+ // _saved_filenames_synthesis has processed all the files in the analysis images folder
+ while(!_RUN_DONE && _state != STATE_STOP)
+ Thread::sleep(3);
+ */
+
- for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
-
- //cout << "CamNoiseAnalysis::synthesis FOR LOOP...\n";
-
- //cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
-
- if(_state == STATE_STOP) return;
-
- if(!image1.loadImage(_saved_filenames_analysis[i])){
- //couldn't load image
- cout << "didn't load image" << endl;
- }
-
- if(image1.loadImage(_saved_filenames_analysis[i])){
- //cout << "LOADED image1!!!" << endl;
- //if(image5.loadImage(_saved_filenames_analysis[i+1])){
-
- ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
-
- cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
- //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
-
- cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
- // cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
- //added by tom we weren't actually setting cvgrayimage1 anywhere
- // cvGrayImage1.setFromPixels(cvColorImage1.getPixels(),cvColorImage1.width,cvColorImage1.height);
- //cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
-//cvGrayImage1=cvColorImage1;
-
- cvGrayImage1.erode();
- cvGrayImage1.erode();
- cvGrayImage1.erode();
- cvGrayImage1.blur();
- cvGrayImage1.contrastStretch();
- /* cvColorImage1.erode();
- cvColorImage1.erode();
- cvColorImage1.erode();
- cvColorImage1.blur();
- cvColorImage1.contrastStretch();*/
-
- /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
- string file_name;
-
- file_name = ofToString(_synth_save_cnt, 2)+"_CamNoiseAnalysis_"+ofToString(_run_cnt,2)+".jpg";
-
-
- //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ---->
- // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
-
-
- //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
- //ofImage image;
- //image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE);
-
- //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
- //image.setUseTexture(false);
-
- //image.setFromPixels(cvGrayImage1.getPixels(), cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE);
- //image.saveImage(_whole_file_path_synthesis+"/"+file_name);
-
- //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
-
- // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
- cvConvertorImage.setFromGrayscalePlanarImages(cvGrayImage1,cvGrayImage1,cvGrayImage1);
- //cvConvertorImage.setFromGrayscalePlanarImages(cvColorImage1,cvColorImage1,cvColorImage1);
- saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
- _synth_save_cnt++;
-
-
- //}
- }
- }
-
- // _saved_filenames_synthesis has processed all the files in the analysis images folder
- while(!_RUN_DONE && _state != STATE_STOP)
- Thread::sleep(3);
}
void CamNoiseAnalysis::displayresults()
{
- for(float i=1;i<_saved_filenames_synthesis.size();i++){
-
+ for(float i=1;i<_saved_filenames_analysis.size();i++){
+
if(_state == STATE_STOP) return;
-
+
//cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
-
+
while(!_image_shown){
Thread::sleep(2);
//cout << "!_image_shown" << endl;
}
-
- if(!image3.loadImage(_saved_filenames_synthesis[i])){
+
+ _show_image = false;
+
+
+ if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image
cout << "didn't load image" << endl;
- }
-
- if(image3.loadImage(_saved_filenames_synthesis[i])){
- image3.loadImage(_saved_filenames_synthesis[i]);
+ }
+
+ if(image1.loadImage(_saved_filenames_analysis[i])){
//cout << "_show_image = true;" << endl;
_show_image = true;
_image_shown = false;
}
- }
+ }
}
@@ -389,31 +308,55 @@ void CamNoiseAnalysis::draw()
case STATE_DISPLAY_RESULTS:
{
- //cout << "STATE_DISPLAY_RESULTS...\n" << endl;
-
if (_frame_cnt > 2)
{
_image_shown = true;
_frame_cnt=0;
}
-
+
_frame_cnt++;
-
+
+ ofEnableAlphaBlending();
+ glShadeModel(GL_SMOOTH);
+ glLineWidth(line_width);
+ glPointSize(point_size);
+ glEnable(GL_POINT_SMOOTH);
+
+ RefractiveIndex::cam.begin();
+
+ ofTranslate(tx, ty, tz);
+ ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
+ glScalef(1.5, 1, 1);
+
if (_show_image)
- {
- //cout << "_show_image...\n" << endl;
-
- ofEnableAlphaBlending();
-
- ofSetColor(255, 255, 255);
- image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR);
- image2.draw(0,0, ofGetWidth(), ofGetHeight());
-
- ofDisableAlphaBlending();
+ image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
+
+ image2.bind();
+
+ RefractiveIndex::_shader.begin();
+
+ RefractiveIndex::_shader.setUniform1i("algo", algo);
+ RefractiveIndex::_shader.setUniform1f("scale", scale);
+ RefractiveIndex::_shader.setUniform1i("tex0", 0);
+
+ switch (draw_style) {
+ case VERTS:
+ RefractiveIndex::_mesh_vbo.drawVertices();
+ break;
+ case WIRE:
+ RefractiveIndex::_mesh_vbo.drawWireframe();
+ break;
+ case FACE:
+ RefractiveIndex::_mesh_vbo.drawFaces();
+ break;
}
-
- // display results of the synthesis
- _RUN_DONE = true;
+
+ RefractiveIndex::_shader.end();
+
+ image2.unbind();
+
+ RefractiveIndex::cam.end();
+
break;
}
diff --git a/src/CamNoiseAnalysis.h b/src/CamNoiseAnalysis.h
index 1d598fd..31573e5 100755
--- a/src/CamNoiseAnalysis.h
+++ b/src/CamNoiseAnalysis.h
@@ -37,31 +37,13 @@ protected:
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
bool _show_image, _image_shown;
+
ofImage image1;
ofImage image2;
- ofImage image3;
- ofImage image4;
- ofImage image5;
- ofImage image6;
-
- ofxCvColorImage cvColorImage1;
- ofxCvColorImage cvColorImage2;
- ofxCvColorImage cvColorImage3;
- ofxCvColorImage cvColorImage4;
- ofxCvColorImage cvColorImage5;
- ofxCvColorImage cvColorImage6;
-
- ofxCvGrayscaleImage cvGrayDiff1;
- ofxCvGrayscaleImage cvGrayDiff2;
-
- ofxCvGrayscaleImage cvGrayImage1;
- ofxCvGrayscaleImage cvGrayImage2;
- ofxCvGrayscaleImage cvGrayImage3;
- ofxCvGrayscaleImage cvGrayImage4;
-
- ofxCvContourFinder cvContourFinder1;
-
- //this is the temporary container to allow us to convert and save out greyscale images
- ofxCvColorImage cvConvertorImage;
+ int algo;
+ int scale;
+ int draw_style;
+ float line_width;
+ float point_size;
};
diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp
index 6c17b5a..abe98d1 100755
--- a/src/ColorMultiAnalysis.cpp
+++ b/src/ColorMultiAnalysis.cpp
@@ -101,14 +101,20 @@ void ColorMultiAnalysis::acquire()
void ColorMultiAnalysis::synthesise()
{
- //cout << "ColorMultiAnalysis::saving synthesis...\n";
- if(_state == STATE_STOP) return;
-
- _RUN_DONE = false;
+ // we don't need to synthesise
+ return;
- // _saved_filenames_synthesis has processed all the files in the analysis images folder
- while(!_RUN_DONE && _state != STATE_STOP)
- Thread::sleep(3);
+ /*
+
+ //cout << "IResponseAnalysis::saving synthesis...\n";
+ if(_state == STATE_STOP) return;
+
+ _RUN_DONE = false;
+
+ // _saved_filenames_synthesis has processed all the files in the analysis images folder
+ while(!_RUN_DONE && _state != STATE_STOP)
+ Thread::sleep(3);
+ */
}
void ColorMultiAnalysis::displayresults()
diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp
index cc7c78c..bfaf4a3 100755
--- a/src/ColorSingleAnalysis.cpp
+++ b/src/ColorSingleAnalysis.cpp
@@ -13,6 +13,11 @@ using Poco::Thread;
#define NUMBER_RUNS 1
#define ACQUIRE_TIME 20
+const int algo_default = 1;
+const int scale_default = 500;
+const int draw_style_default = 3;
+const float line_width_default = 0.5f;
+
void ColorSingleAnalysis::setup(int camWidth, int camHeight)
{
AbstractAnalysis::setup(camWidth, camHeight);
@@ -53,50 +58,21 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
image1.clear();
image2.clear();
- image3.clear();
- image4.clear();
- image5.clear();
// images use for drawing the synthesized files to the screen ///
image1.setUseTexture(false); // the non texture image that is needed to first load the image
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
- // images used for re-loading and saving out the synthesized files ///
- image3.setUseTexture(false);
- image4.setUseTexture(false);
- image5.setUseTexture(false);
-
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- //cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
- //cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
- // clear() apparently fixes the "OF_WARNING: in allocate, reallocating a ofxCvImage"
- // that we're getting in OSX/Windows and is maybe crashing Windows
- // http://forum.openframeworks.cc/index.php?topic=1867.0
- cvColorImage1.clear();
- cvGrayImage1.clear();
- cvGrayDiff1.clear();
+ ////---------
- cvColorImage2.clear();
- cvGrayImage2.clear();
- cvGrayDiff2.clear();
-
- cvConvertorImage.clear();
-
- cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
+ algo = RefractiveIndex::XML.getValue("config:algorithms:colorsingle:algo", algo_default);
+ scale = RefractiveIndex::XML.getValue("config:algorithms:colorsingle:scale", scale_default);
+ draw_style = RefractiveIndex::XML.getValue("config:algorithms:colorsingle:draw_style", draw_style_default);
+ line_width = RefractiveIndex::XML.getValue("config:algorithms:colorsingle:line_width", line_width_default);
}
@@ -133,81 +109,26 @@ void ColorSingleAnalysis::acquire()
void ColorSingleAnalysis::synthesise()
{
- //cout << "ColorSingleAnalysis::saving synthesis...\n";
- if(_state == STATE_STOP) return;
+ // we don't need to synthesise
+ return;
- for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
-
- //cout << "ColorSingleAnalysis::synthesis FOR LOOP...\n";
-
- //cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
-
- if(_state == STATE_STOP) return;
-
- if(!image1.loadImage(_saved_filenames_analysis[i])){
- //couldn't load image
- cout << "didn't load image" << endl;
- }
-
- if(image1.loadImage(_saved_filenames_analysis[i])){
- //cout << "LOADED image1!!!" << endl;
- //if(image5.loadImage(_saved_filenames_analysis[i+1])){
-
- ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
-
- cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
- //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
-
- cvColorImage1.blur(5);
- cvColorImage1.erode();
- cvColorImage1.erode();
- cvColorImage1.dilate();
- cvColorImage1.blur(5);
- cvColorImage1.erode();
- cvColorImage1.erode();
- cvColorImage1.erode();
- cvColorImage1.erode();
-
- /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
- string file_name;
-
- file_name = ofToString(_synth_save_cnt, 2)+"_ColorSingleAnalysis_"+ofToString(_run_cnt,2)+".jpg";
-
-
- //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ---->
- // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
-
-
- //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
- //ofImage image;
- //image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR);
-
- //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
- //image.setUseTexture(false);
-
- //image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR);
- //image.saveImage(_whole_file_path_synthesis+"/"+file_name);
-
- //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
-
- // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
-
- saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
- _synth_save_cnt++;
-
- // }
- }
- }
-
- // _saved_filenames_synthesis has processed all the files in the analysis images folder
- while(!_RUN_DONE && _state != STATE_STOP)
- Thread::sleep(3);
+ /*
+
+ //cout << "IResponseAnalysis::saving synthesis...\n";
+ if(_state == STATE_STOP) return;
+
+ _RUN_DONE = false;
+
+ // _saved_filenames_synthesis has processed all the files in the analysis images folder
+ while(!_RUN_DONE && _state != STATE_STOP)
+ Thread::sleep(3);
+ */
}
void ColorSingleAnalysis::displayresults()
{
- for(float i=1;i<_saved_filenames_synthesis.size();i++){
+ for(float i=1;i<_saved_filenames_analysis.size();i++){
if(_state == STATE_STOP) return;
@@ -218,18 +139,20 @@ void ColorSingleAnalysis::displayresults()
//cout << "!_image_shown" << endl;
}
- if(!image3.loadImage(_saved_filenames_synthesis[i])){
+ _show_image = false;
+
+
+ if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image
cout << "didn't load image" << endl;
}
- if(image3.loadImage(_saved_filenames_synthesis[i])){
- image3.loadImage(_saved_filenames_synthesis[i]);
+ if(image1.loadImage(_saved_filenames_analysis[i])){
//cout << "_show_image = true;" << endl;
_show_image = true;
_image_shown = false;
}
- }
+ }
}
@@ -389,7 +312,6 @@ void ColorSingleAnalysis::draw()
//cout << "STATE_DISPLAY_RESULTS...\n" << endl;
-
if (_frame_cnt > 2)
{
_image_shown = true;
@@ -398,20 +320,46 @@ void ColorSingleAnalysis::draw()
_frame_cnt++;
+
+ ofEnableAlphaBlending();
+ glShadeModel(GL_SMOOTH);
+ glLineWidth(line_width);
+
+ RefractiveIndex::cam.begin();
+
+ ofTranslate(tx, ty, tz);
+ ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
+ glScalef(1.5, 1, 1);
+
if (_show_image)
- {
- //cout << "_show_image...\n" << endl;
-
- ofEnableAlphaBlending();
-
- ofSetColor(255, 255, 255);
- image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR);
- image2.draw(0,0, ofGetWidth(), ofGetHeight());
-
- ofDisableAlphaBlending();
+ image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
+
+ image2.bind();
+
+ RefractiveIndex::_shader.begin();
+
+ RefractiveIndex::_shader.setUniform1i("algo", algo);
+ RefractiveIndex::_shader.setUniform1f("scale", scale);
+ RefractiveIndex::_shader.setUniform1i("tex0", 0);
+
+ switch (draw_style) {
+ case VERTS:
+ RefractiveIndex::_mesh_vbo.drawVertices();
+ break;
+ case WIRE:
+ RefractiveIndex::_mesh_vbo.drawWireframe();
+ break;
+ case FACE:
+ RefractiveIndex::_mesh_vbo.drawFaces();
+ break;
}
- // display results of the synthesis
+ RefractiveIndex::_shader.end();
+
+ image2.unbind();
+
+ RefractiveIndex::cam.end();
+
_RUN_DONE = true;
break;
diff --git a/src/ColorSingleAnalysis.h b/src/ColorSingleAnalysis.h
index 6a9a8dd..ac4540a 100755
--- a/src/ColorSingleAnalysis.h
+++ b/src/ColorSingleAnalysis.h
@@ -38,32 +38,13 @@ protected:
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
bool _show_image, _image_shown;
+
ofImage image1;
ofImage image2;
- ofImage image3;
- ofImage image4;
- ofImage image5;
- ofImage image6;
-
- ofxCvColorImage cvColorImage1;
- ofxCvColorImage cvColorImage2;
- ofxCvColorImage cvColorImage3;
- ofxCvColorImage cvColorImage4;
- ofxCvColorImage cvColorImage5;
- ofxCvColorImage cvColorImage6;
-
- ofxCvGrayscaleImage cvGrayDiff1;
- ofxCvGrayscaleImage cvGrayDiff2;
-
- ofxCvGrayscaleImage cvGrayImage1;
- ofxCvGrayscaleImage cvGrayImage2;
- ofxCvGrayscaleImage cvGrayImage3;
- ofxCvGrayscaleImage cvGrayImage4;
-
- ofxCvContourFinder cvContourFinder1;
-
- //this is the temporary container to allow us to convert and save out greyscale images
- ofxCvColorImage cvConvertorImage;
+ int algo;
+ int scale;
+ int draw_style;
+ float line_width;
};
diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp
index 5a48dad..c52ce7f 100755
--- a/src/DiffNoiseAnalysis.cpp
+++ b/src/DiffNoiseAnalysis.cpp
@@ -13,6 +13,12 @@ using Poco::Thread;
#define NUMBER_RUNS 1
#define ACQUIRE_TIME 20
+const int algo_default = 1;
+const int scale_default = 500;
+const int draw_style_default = 3;
+const int line_width_default = 0.5f;
+const float point_size_default = 0.5f;
+
void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
{
AbstractAnalysis::setup(camWidth, camHeight);
@@ -47,50 +53,22 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
image1.clear();
image2.clear();
- image3.clear();
- image4.clear();
- image5.clear();
// images use for drawing the synthesized files to the screen ///
image1.setUseTexture(false); // the non texture image that is needed to first load the image
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
- // images used for re-loading and saving out the synthesized files ///
- image3.setUseTexture(false);
- image4.setUseTexture(false);
- image5.setUseTexture(false);
-
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- //cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
- //cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
- // clear() apparently fixes the "OF_WARNING: in allocate, reallocating a ofxCvImage"
- // that we're getting in OSX/Windows and is maybe crashing Windows
- // http://forum.openframeworks.cc/index.php?topic=1867.0
- cvColorImage1.clear();
- cvGrayImage1.clear();
- cvGrayDiff1.clear();
+ ////---------
- cvColorImage2.clear();
- cvGrayImage2.clear();
- cvGrayDiff2.clear();
-
- cvConvertorImage.clear();
-
- cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
+ algo = RefractiveIndex::XML.getValue("config:algorithms:diffnoise:algo", algo_default);
+ scale = RefractiveIndex::XML.getValue("config:algorithms:diffnoise:scale", scale_default);
+ draw_style = RefractiveIndex::XML.getValue("config:algorithms:diffnoise:draw_style", draw_style_default);
+ line_width = RefractiveIndex::XML.getValue("config:algorithms:diffnoise:line_width", line_width_default);
+ point_size = RefractiveIndex::XML.getValue("config:algorithms:diffnoise:point_size", point_size_default);
}
@@ -126,79 +104,27 @@ void DiffNoiseAnalysis::acquire()
void DiffNoiseAnalysis::synthesise()
{
- //cout << "DiffNoiseAnalysis::saving synthesis...\n";
- if(_state == STATE_STOP) return;
+ // we don't need to synthesise
+ return;
- for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
-
- //cout << "DiffNoiseAnalysis::synthesis FOR LOOP...\n";
-
- //cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
-
- if(_state == STATE_STOP) return;
-
- if(!image1.loadImage(_saved_filenames_analysis[i])){
- //couldn't load image
- cout << "didn't load image" << endl;
- }
-
- if(image1.loadImage(_saved_filenames_analysis[i])){
- //cout << "LOADED image1!!!" << endl;
- //if(image5.loadImage(_saved_filenames_analysis[i+1])){
-
- ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
-
- cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
- //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
-
- cvColorImage1.invert();
- cvColorImage1.blur(5);
- cvColorImage1.erode();
- cvColorImage1.erode();
- cvColorImage1.blur(5);
- cvColorImage1.erode();
- cvColorImage1.erode();
-
- //////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
- string file_name;
-
- file_name = ofToString(_synth_save_cnt, 2)+"_DiffNoiseAnalysis_"+ofToString(_run_cnt,2)+".jpg";
-
-
- //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ---->
- // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
-
-
- //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
- //ofImage image;
- //image.allocate(cvColorImage1.width, cvGrayImage1.height, OF_IMAGE_COLOR);
-
- //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
- //image.setUseTexture(false);
-
- //image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR);
- //image.saveImage(_whole_file_path_synthesis+"/"+file_name);
-
- //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
-
- // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
- saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
- _synth_save_cnt++;
-
- // }
- }
- }
-
- // _saved_filenames_synthesis has processed all the files in the analysis images folder
- while(!_RUN_DONE && _state != STATE_STOP)
- Thread::sleep(3);
+ /*
+
+ //cout << "IResponseAnalysis::saving synthesis...\n";
+ if(_state == STATE_STOP) return;
+
+ _RUN_DONE = false;
+
+ // _saved_filenames_synthesis has processed all the files in the analysis images folder
+ while(!_RUN_DONE && _state != STATE_STOP)
+ Thread::sleep(3);
+ */
}
void DiffNoiseAnalysis::displayresults()
{
- for(float i=1;i<_saved_filenames_synthesis.size();i++){
+ for(float i=1;i<_saved_filenames_analysis.size();i++){
if(_state == STATE_STOP) return;
@@ -209,19 +135,20 @@ void DiffNoiseAnalysis::displayresults()
//cout << "!_image_shown" << endl;
}
- if(!image3.loadImage(_saved_filenames_synthesis[i])){
+ _show_image = false;
+
+
+ if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image
cout << "didn't load image" << endl;
}
- if(image3.loadImage(_saved_filenames_synthesis[i])){
- image3.loadImage(_saved_filenames_synthesis[i]);
+ if(image1.loadImage(_saved_filenames_analysis[i])){
//cout << "_show_image = true;" << endl;
_show_image = true;
_image_shown = false;
}
- }
-
+ }
}
@@ -392,9 +319,6 @@ void DiffNoiseAnalysis::draw()
case STATE_DISPLAY_RESULTS:
{
- //cout << "STATE_DISPLAY_RESULTS...\n" << endl;
-
-
if (_frame_cnt > 2)
{
_image_shown = true;
@@ -403,22 +327,47 @@ void DiffNoiseAnalysis::draw()
_frame_cnt++;
+ ofEnableAlphaBlending();
+ glShadeModel(GL_SMOOTH);
+ glLineWidth(line_width);
+ glPointSize(point_size);
+ glEnable(GL_POINT_SMOOTH);
+
+ RefractiveIndex::cam.begin();
+
+ ofTranslate(tx, ty, tz);
+ ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
+ glScalef(1.5, 1, 1);
+
if (_show_image)
- {
- //cout << "_show_image...\n" << endl;
-
- ofEnableAlphaBlending();
-
- ofSetColor(255, 255, 255);
- image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR);
- //image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_GRAYSCALE);
- image2.draw(0,0, ofGetWidth(), ofGetHeight());
-
- ofDisableAlphaBlending();
+ image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
+
+ image2.bind();
+
+ RefractiveIndex::_shader.begin();
+
+ RefractiveIndex::_shader.setUniform1i("algo", algo);
+ RefractiveIndex::_shader.setUniform1f("scale", scale);
+ RefractiveIndex::_shader.setUniform1i("tex0", 0);
+
+ switch (draw_style) {
+ case VERTS:
+ RefractiveIndex::_mesh_vbo.drawVertices();
+ break;
+ case WIRE:
+ RefractiveIndex::_mesh_vbo.drawWireframe();
+ break;
+ case FACE:
+ RefractiveIndex::_mesh_vbo.drawFaces();
+ break;
}
- // display results of the synthesis
- _RUN_DONE = true;
+ RefractiveIndex::_shader.end();
+
+ image2.unbind();
+
+ RefractiveIndex::cam.end();
+
break;
}
diff --git a/src/DiffNoiseAnalysis.h b/src/DiffNoiseAnalysis.h
index 1f4efa0..0e32bd0 100755
--- a/src/DiffNoiseAnalysis.h
+++ b/src/DiffNoiseAnalysis.h
@@ -36,31 +36,14 @@ protected:
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
bool _show_image, _image_shown;
+
ofImage image1;
ofImage image2;
- ofImage image3;
- ofImage image4;
- ofImage image5;
- ofImage image6;
- ofxCvColorImage cvColorImage1;
- ofxCvColorImage cvColorImage2;
- ofxCvColorImage cvColorImage3;
- ofxCvColorImage cvColorImage4;
- ofxCvColorImage cvColorImage5;
- ofxCvColorImage cvColorImage6;
-
- ofxCvGrayscaleImage cvGrayDiff1;
- ofxCvGrayscaleImage cvGrayDiff2;
-
- ofxCvGrayscaleImage cvGrayImage1;
- ofxCvGrayscaleImage cvGrayImage2;
- ofxCvGrayscaleImage cvGrayImage3;
- ofxCvGrayscaleImage cvGrayImage4;
-
- ofxCvContourFinder cvContourFinder1;
-
- //this is the temporary container to allow us to convert and save out greyscale images
- ofxCvColorImage cvConvertorImage;
+ int algo;
+ int scale;
+ int draw_style;
+ float line_width;
+ float point_size;
};
diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp
index 884f6a9..6be0889 100755
--- a/src/IResponseAnalysis.cpp
+++ b/src/IResponseAnalysis.cpp
@@ -13,6 +13,13 @@ using Poco::Thread;
#define NUMBER_RUNS 1
#define ACQUIRE_TIME 20
+const int algo_default = 1;
+const int scale_default = 500;
+const int draw_style_default = 3;
+const int line_width_default = 0.5f;
+const float point_size_default = 0.5f;
+
+
void IResponseAnalysis::setup(int camWidth, int camHeight)
{
AbstractAnalysis::setup(camWidth, camHeight);
@@ -47,51 +54,22 @@ void IResponseAnalysis::setup(int camWidth, int camHeight)
image1.clear();
image2.clear();
- image3.clear();
- image4.clear();
- image5.clear();
// images use for drawing the synthesized files to the screen ///
image1.setUseTexture(false); // the non texture image that is needed to first load the image
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
- // images used for re-loading and saving out the synthesized files ///
- image3.setUseTexture(false);
- image4.setUseTexture(false);
- image5.setUseTexture(false);
-
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- //cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
- //cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
- // clear() apparently fixes the "OF_WARNING: in allocate, reallocating a ofxCvImage"
- // that we're getting in OSX/Windows and is maybe crashing Windows
- // http://forum.openframeworks.cc/index.php?topic=1867.0
- cvColorImage1.clear();
- cvGrayImage1.clear();
- cvGrayDiff1.clear();
-
- cvColorImage2.clear();
- cvGrayImage2.clear();
- cvGrayDiff2.clear();
-
- cvConvertorImage.clear();
-
- cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
+ ////---------
+ algo = RefractiveIndex::XML.getValue("config:algorithms:iresponse:algo", algo_default);
+ scale = RefractiveIndex::XML.getValue("config:algorithms:iresponse:scale", scale_default);
+ draw_style = RefractiveIndex::XML.getValue("config:algorithms:iresponse:draw_style", draw_style_default);
+ line_width = RefractiveIndex::XML.getValue("config:algorithms:iresponse:line_width", line_width_default);
+ point_size = RefractiveIndex::XML.getValue("config:algorithms:iresponse:point_size", point_size_default);
}
@@ -126,86 +104,27 @@ void IResponseAnalysis::acquire()
void IResponseAnalysis::synthesise()
{
- //cout << "IResponseAnalysis::saving synthesis...\n";
- if(_state == STATE_STOP) return;
-
- for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
-
- //cout << "IResponseAnalysis::synthesis FOR LOOP...\n";
-
- //cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
-
- if(_state == STATE_STOP) return;
-
- if(!image1.loadImage(_saved_filenames_analysis[i])){
- //couldn't load image
- cout << "didn't load image" << endl;
- }
-
- if(image1.loadImage(_saved_filenames_analysis[i])){
- //cout << "LOADED image1!!!" << endl;
- if(image5.loadImage(_saved_filenames_analysis[i+1])){
-
- ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
-
- cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
- cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
-
- cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
- cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
-
- cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
- cvGrayDiff1.erode();
- cvGrayDiff1.contrastStretch();
- //cvGrayDiff1.blur(5);
- //cvGrayDiff1.dilate();
- //cvGrayDiff1.contrastStretch();
-
- /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
- string file_name;
-
- file_name = ofToString(_synth_save_cnt, 2)+"_IResponseSynthesis_"+ofToString(_run_cnt,2)+".jpg";
-
-
- //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ---->
- // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
-
-
- //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
- //ofImage image;
- //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE);
-
- //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
- //image.setUseTexture(false);
- //image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE);
- //image.saveImage(_whole_file_path_synthesis+"/"+file_name);
- //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
-
-
- // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
- cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
-
- saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
-
- _synth_save_cnt++;
-
-
-
- }
- }
- }
-
- // _saved_filenames_synthesis has processed all the files in the analysis images folder
- while(!_RUN_DONE && _state != STATE_STOP)
- Thread::sleep(3);
+ // we don't need to synthesise
+ return;
+ /*
+
+ //cout << "IResponseAnalysis::saving synthesis...\n";
+ if(_state == STATE_STOP) return;
+
+ _RUN_DONE = false;
+
+ // _saved_filenames_synthesis has processed all the files in the analysis images folder
+ while(!_RUN_DONE && _state != STATE_STOP)
+ Thread::sleep(3);
+ */
}
void IResponseAnalysis::displayresults()
{
- for(float i=1;i<_saved_filenames_synthesis.size();i++){
+ for(float i=1;i<_saved_filenames_analysis.size();i++){
if(_state == STATE_STOP) return;
@@ -216,18 +135,20 @@ void IResponseAnalysis::displayresults()
//cout << "!_image_shown" << endl;
}
- if(!image3.loadImage(_saved_filenames_synthesis[i])){
+ _show_image = false;
+
+
+ if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image
- // cout << "didn't load image" << endl;
+ cout << "didn't load image" << endl;
}
- if(image3.loadImage(_saved_filenames_synthesis[i])){
- image3.loadImage(_saved_filenames_synthesis[i]);
+ if(image1.loadImage(_saved_filenames_analysis[i])){
//cout << "_show_image = true;" << endl;
_show_image = true;
_image_shown = false;
}
- }
+ }
}
@@ -363,8 +284,6 @@ void IResponseAnalysis::draw()
case STATE_DISPLAY_RESULTS:
{
- //cout << "STATE_DISPLAY_RESULTS...\n" << endl;
-
if (_frame_cnt > 2)
{
_image_shown = true;
@@ -373,21 +292,47 @@ void IResponseAnalysis::draw()
_frame_cnt++;
- if (_show_image)
- {
- //cout << "_show_image...\n" << endl;
-
- ofEnableAlphaBlending();
-
- ofSetColor(255, 255, 255);
- image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR);
- image2.draw(0,0, ofGetWidth(), ofGetHeight());
+ ofEnableAlphaBlending();
+ glShadeModel(GL_SMOOTH);
+ glLineWidth(line_width);
+ glPointSize(point_size);
+ glEnable(GL_POINT_SMOOTH);
- ofDisableAlphaBlending();
+ RefractiveIndex::cam.begin();
+
+ ofTranslate(tx, ty, tz);
+ ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
+ glScalef(1.5, 1, 1);
+
+ if (_show_image)
+ image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
+
+ image2.bind();
+
+ RefractiveIndex::_shader.begin();
+
+ RefractiveIndex::_shader.setUniform1i("algo", algo);
+ RefractiveIndex::_shader.setUniform1f("scale", scale);
+ RefractiveIndex::_shader.setUniform1i("tex0", 0);
+
+ switch (draw_style) {
+ case VERTS:
+ RefractiveIndex::_mesh_vbo.drawVertices();
+ break;
+ case WIRE:
+ RefractiveIndex::_mesh_vbo.drawWireframe();
+ break;
+ case FACE:
+ RefractiveIndex::_mesh_vbo.drawFaces();
+ break;
}
- // display results of the synthesis
- _RUN_DONE = true;
+ RefractiveIndex::_shader.end();
+
+ image2.unbind();
+
+ RefractiveIndex::cam.end();
+
break;
}
diff --git a/src/IResponseAnalysis.h b/src/IResponseAnalysis.h
index ebd471f..c2edb21 100755
--- a/src/IResponseAnalysis.h
+++ b/src/IResponseAnalysis.h
@@ -35,31 +35,14 @@ protected:
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
bool _show_image, _image_shown;
+
ofImage image1;
ofImage image2;
- ofImage image3;
- ofImage image4;
- ofImage image5;
- ofImage image6;
- ofxCvColorImage cvColorImage1;
- ofxCvColorImage cvColorImage2;
- ofxCvColorImage cvColorImage3;
- ofxCvColorImage cvColorImage4;
- ofxCvColorImage cvColorImage5;
- ofxCvColorImage cvColorImage6;
-
- ofxCvGrayscaleImage cvGrayDiff1;
- ofxCvGrayscaleImage cvGrayDiff2;
-
- ofxCvGrayscaleImage cvGrayImage1;
- ofxCvGrayscaleImage cvGrayImage2;
- ofxCvGrayscaleImage cvGrayImage3;
- ofxCvGrayscaleImage cvGrayImage4;
-
- ofxCvContourFinder cvContourFinder1;
-
- //this is the temporary container to allow us to convert and save out greyscale images
- ofxCvColorImage cvConvertorImage;
+ int algo;
+ int scale;
+ int draw_style;
+ float line_width;
+ float point_size;
};
diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp
index fd50b68..3b4cf94 100755
--- a/src/RelaxRateAnalysis.cpp
+++ b/src/RelaxRateAnalysis.cpp
@@ -12,8 +12,6 @@ using Poco::Thread;
#define NUMBER_RUNS 1
#define ACQUIRE_TIME 20
-#define TRESHOLD 80
-#define MAXBLOBS 15
const int algo_default = 1;
const int scale_default = 500;
@@ -33,15 +31,6 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
acq_run_time = RefractiveIndex::XML.getValue("config:analysis_time:acquiretime_relaxrate", ACQUIRE_TIME);
cout << "ACQUIRE_TIME RelaxRateAnalysis " << acq_run_time << endl;
- _treshold = RefractiveIndex::XML.getValue("config:relaxrate:treshold", TRESHOLD);
- cout << "TRESHOLD RelaxRateAnalysis " << _treshold << endl;
-
- _maxblobs = RefractiveIndex::XML.getValue("config:relaxrate:maxblobs", MAXBLOBS);
- cout << "MAXBLOBS RelaxRateAnalysis " << _maxblobs << endl;
-
-
- //int acq_run_time = 20; // 20 seconds of acquiring per run
-
DELTA_T_SAVE = 2*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files
// or 10 times per second = every 100 ms
@@ -113,6 +102,11 @@ void RelaxRateAnalysis::acquire()
void RelaxRateAnalysis::synthesise()
{
+ // we don't need to synthesise
+ return;
+
+ /*
+
//cout << "IResponseAnalysis::saving synthesis...\n";
if(_state == STATE_STOP) return;
@@ -121,6 +115,7 @@ void RelaxRateAnalysis::synthesise()
// _saved_filenames_synthesis has processed all the files in the analysis images folder
while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3);
+ */
}
@@ -335,7 +330,6 @@ void RelaxRateAnalysis::draw()
RefractiveIndex::cam.end();
- //_RUN_DONE = true;
break;
}
@@ -353,8 +347,6 @@ void RelaxRateAnalysis::save_cb(Timer& timer)
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
- saveImageAnalysis(file_name);
-
-
+ saveImageAnalysis(file_name);
}
diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp
index 65617d4..784fc47 100755
--- a/src/ShadowScapesAnalysis.cpp
+++ b/src/ShadowScapesAnalysis.cpp
@@ -102,15 +102,20 @@ void ShadowScapesAnalysis::acquire()
void ShadowScapesAnalysis::synthesise()
{
- //cout << "ShadowScapesAnalysis::saving synthesis...\n";
+ // we don't need to synthesise
+ return;
- if(_state == STATE_STOP) return;
-
- _RUN_DONE = false;
-
- // _saved_filenames_synthesis has processed all the files in the analysis images folder
- while(!_RUN_DONE && _state != STATE_STOP)
- Thread::sleep(3);
+ /*
+
+ //cout << "IResponseAnalysis::saving synthesis...\n";
+ if(_state == STATE_STOP) return;
+
+ _RUN_DONE = false;
+
+ // _saved_filenames_synthesis has processed all the files in the analysis images folder
+ while(!_RUN_DONE && _state != STATE_STOP)
+ Thread::sleep(3);
+ */
}
diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp
index a2bf3ae..171d8f2 100755
--- a/src/ShapeFromShadingAnalysis.cpp
+++ b/src/ShapeFromShadingAnalysis.cpp
@@ -13,6 +13,13 @@ using Poco::Thread;
#define NUMBER_RUNS 1
#define ACQUIRE_TIME 20
+const int algo_default = 1;
+const int scale_default = 500;
+const int draw_style_default = 3;
+const int line_width_default = 0.5f;
+const float point_size_default = 0.5f;
+
+
void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
{
AbstractAnalysis::setup(camWidth, camHeight);
@@ -47,50 +54,21 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
image1.clear();
image2.clear();
- image3.clear();
- image4.clear();
- image5.clear();
- // images use for drawing the synthesized files to the screen ///
- image1.setUseTexture(false); // the non texture image that is needed to first load the image
- image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
-
- // images used for re-loading and saving out the synthesized files ///
- image3.setUseTexture(false);
- image4.setUseTexture(false);
- image5.setUseTexture(false);
+ image1.setUseTexture(false);
+ image2.setUseTexture(true);
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- // cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
- // cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
+ ////---------
- // clear() apparently fixes the "OF_WARNING: in allocate, reallocating a ofxCvImage"
- // that we're getting in OSX/Windows and is maybe crashing Windows
- // http://forum.openframeworks.cc/index.php?topic=1867.0
- cvColorImage1.clear();
- cvGrayImage1.clear();
- cvGrayDiff1.clear();
-
- cvColorImage2.clear();
- cvGrayImage2.clear();
- cvGrayDiff2.clear();
-
- cvConvertorImage.clear();
-
- cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
+ algo = RefractiveIndex::XML.getValue("config:algorithms:shapeshade:algo", algo_default);
+ scale = RefractiveIndex::XML.getValue("config:algorithms:shapeshade:scale", scale_default);
+ draw_style = RefractiveIndex::XML.getValue("config:algorithms:shapeshade:draw_style", draw_style_default);
+ line_width = RefractiveIndex::XML.getValue("config:algorithms:shapeshade:line_width", line_width_default);
+ point_size = RefractiveIndex::XML.getValue("config:algorithms:shapeshade:point_size", point_size_default);
+
}
@@ -146,104 +124,51 @@ void ShapeFromShadingAnalysis::acquire()
void ShapeFromShadingAnalysis::synthesise()
{
- // cout << "ShapeFromShadingAnalysis::saving synthesis...\n";
- if(_state == STATE_STOP) return;
+ // we don't need to synthesise
+ return;
- for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
-
- // cout << "ShapeFromShadingAnalysis::synthesis FOR LOOP...\n";
-
- // cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
+ /*
+
+ //cout << "IResponseAnalysis::saving synthesis...\n";
+ if(_state == STATE_STOP) return;
+
+ _RUN_DONE = false;
+
+ // _saved_filenames_synthesis has processed all the files in the analysis images folder
+ while(!_RUN_DONE && _state != STATE_STOP)
+ Thread::sleep(3);
+ */
+
+
+}
+
+void ShapeFromShadingAnalysis::displayresults()
+{
+ for(float i=1;i<_saved_filenames_analysis.size();i++){
if(_state == STATE_STOP) return;
+ //cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
+
+ while(!_image_shown){
+ Thread::sleep(2);
+ //cout << "!_image_shown" << endl;
+ }
+
+ _show_image = false;
+
+
if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image
cout << "didn't load image" << endl;
}
if(image1.loadImage(_saved_filenames_analysis[i])){
- // cout << "LOADED image1!!!" << endl;
- if(image5.loadImage(_saved_filenames_analysis[i+1])){
-
- ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
-
- cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
- cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
-
- cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
- cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
-
- cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
- cvGrayDiff1.erode();
- cvGrayDiff1.contrastStretch();
- //cvGrayDiff1.blur(5);
- //cvGrayDiff1.dilate();
- //cvGrayDiff1.contrastStretch();
-
- /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
- string file_name;
-
- file_name = ofToString(_synth_save_cnt, 2)+"_ShapeFromShadingSynthesis_"+ofToString(_run_cnt,2)+".jpg";
-
-
- //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ---->
- // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
-
- //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
- //ofImage image;
- //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE);
-
- //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
- //image.setUseTexture(false);
-
- //image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE);
- //image.saveImage(_whole_file_path_synthesis+"/"+file_name);
-
- //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
-
-
- // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
- cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
-
- saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
- _synth_save_cnt++;
-
- }
- }
- }
-
- // _saved_filenames_synthesis has processed all the files in the analysis images folder
- while(!_RUN_DONE && _state != STATE_STOP)
- Thread::sleep(3);
-
-}
-
-void ShapeFromShadingAnalysis::displayresults()
-{
- for(float i=1;i<_saved_filenames_synthesis.size();i++){
-
- if(_state == STATE_STOP) return;
-
- // cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
-
- while(!_image_shown){
- Thread::sleep(2);
- //cout << "!_image_shown" << endl;
- }
-
- if(!image3.loadImage(_saved_filenames_synthesis[i])){
- //couldn't load image
- cout << "didn't load image" << endl;
- }
-
- if(image3.loadImage(_saved_filenames_synthesis[i])){
- image3.loadImage(_saved_filenames_synthesis[i]);
//cout << "_show_image = true;" << endl;
_show_image = true;
_image_shown = false;
}
- }
+ }
}
// this runs at frame rate = 33 ms for 30 FPS
@@ -552,8 +477,6 @@ void ShapeFromShadingAnalysis::draw()
case STATE_DISPLAY_RESULTS:
{
- // cout << "STATE_DISPLAY_RESULTS...\n" << endl;
-
if (_frame_cnt > 2)
{
_image_shown = true;
@@ -562,22 +485,49 @@ void ShapeFromShadingAnalysis::draw()
_frame_cnt++;
+ ofEnableAlphaBlending();
+ glShadeModel(GL_SMOOTH);
+ glLineWidth(line_width);
+ glPointSize(point_size);
+ glEnable(GL_POINT_SMOOTH);
+
+ RefractiveIndex::cam.begin();
+
+ ofTranslate(tx, ty, tz);
+ ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
+ glScalef(1.5, 1, 1);
+
if (_show_image)
- {
- // cout << "_show_image...\n" << endl;
-
- ofEnableAlphaBlending();
-
- ofSetColor(255, 255, 255);
- image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR);
- image2.draw(0,0, ofGetWidth(), ofGetHeight());
-
- ofDisableAlphaBlending();
+ image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
+
+ image2.bind();
+
+ RefractiveIndex::_shader.begin();
+
+ RefractiveIndex::_shader.setUniform1i("algo", algo);
+ RefractiveIndex::_shader.setUniform1f("scale", scale);
+ RefractiveIndex::_shader.setUniform1i("tex0", 0);
+
+ switch (draw_style) {
+ case VERTS:
+ RefractiveIndex::_mesh_vbo.drawVertices();
+ break;
+ case WIRE:
+ RefractiveIndex::_mesh_vbo.drawWireframe();
+ break;
+ case FACE:
+ RefractiveIndex::_mesh_vbo.drawFaces();
+ break;
}
- // display results of the synthesis
- _RUN_DONE = true;
+ RefractiveIndex::_shader.end();
+
+ image2.unbind();
+
+ RefractiveIndex::cam.end();
+
break;
+
}
diff --git a/src/ShapeFromShadingAnalysis.h b/src/ShapeFromShadingAnalysis.h
index 4c94812..fded22f 100755
--- a/src/ShapeFromShadingAnalysis.h
+++ b/src/ShapeFromShadingAnalysis.h
@@ -55,31 +55,14 @@ protected:
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
bool _show_image, _image_shown;
+
ofImage image1;
ofImage image2;
- ofImage image3;
- ofImage image4;
- ofImage image5;
- ofImage image6;
- ofxCvColorImage cvColorImage1;
- ofxCvColorImage cvColorImage2;
- ofxCvColorImage cvColorImage3;
- ofxCvColorImage cvColorImage4;
- ofxCvColorImage cvColorImage5;
- ofxCvColorImage cvColorImage6;
-
- ofxCvGrayscaleImage cvGrayDiff1;
- ofxCvGrayscaleImage cvGrayDiff2;
-
- ofxCvGrayscaleImage cvGrayImage1;
- ofxCvGrayscaleImage cvGrayImage2;
- ofxCvGrayscaleImage cvGrayImage3;
- ofxCvGrayscaleImage cvGrayImage4;
-
- ofxCvContourFinder cvContourFinder1;
-
- //this is the temporary container to allow us to convert and save out greyscale images
- ofxCvColorImage cvConvertorImage;
+ int algo;
+ int scale;
+ int draw_style;
+ float line_width;
+ float point_size;
};
diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp
index b45241a..4e8da06 100755
--- a/src/StrobeAnalysis.cpp
+++ b/src/StrobeAnalysis.cpp
@@ -13,6 +13,12 @@ using Poco::Thread;
#define NUMBER_RUNS 1
#define ACQUIRE_TIME 30
+const int algo_default = 1;
+const int scale_default = 500;
+const int draw_style_default = 3;
+const int line_width_default = 0.5f;
+const float point_size_default = 0.5f;
+
void StrobeAnalysis::setup(int camWidth, int camHeight)
{
AbstractAnalysis::setup(camWidth, camHeight);
@@ -48,51 +54,25 @@ void StrobeAnalysis::setup(int camWidth, int camHeight)
image1.clear();
image2.clear();
- image3.clear();
- image4.clear();
- image5.clear();
+ image1.clear();
+ image2.clear();
// images use for drawing the synthesized files to the screen ///
image1.setUseTexture(false); // the non texture image that is needed to first load the image
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
- // images used for re-loading and saving out the synthesized files ///
- image3.setUseTexture(false);
- image4.setUseTexture(false);
- image5.setUseTexture(false);
-
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
- // cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
- // cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
- // clear() apparently fixes the "OF_WARNING: in allocate, reallocating a ofxCvImage"
- // that we're getting in OSX/Windows and is maybe crashing Windows
- // http://forum.openframeworks.cc/index.php?topic=1867.0
- cvColorImage1.clear();
- cvGrayImage1.clear();
- cvGrayDiff1.clear();
+ ////---------
- cvColorImage2.clear();
- cvGrayImage2.clear();
- cvGrayDiff2.clear();
+ algo = RefractiveIndex::XML.getValue("config:algorithms:strobe:algo", algo_default);
+ scale = RefractiveIndex::XML.getValue("config:algorithms:strobe:scale", scale_default);
+ draw_style = RefractiveIndex::XML.getValue("config:algorithms:strobe:draw_style", draw_style_default);
+ line_width = RefractiveIndex::XML.getValue("config:algorithms:strobe:line_width", line_width_default);
+ point_size = RefractiveIndex::XML.getValue("config:algorithms:strobe:point_size", point_size_default);
- cvConvertorImage.clear();
-
- cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
- cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
- cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
-
}
@@ -128,105 +108,50 @@ void StrobeAnalysis::acquire()
void StrobeAnalysis::synthesise()
{
- // cout << "StrobeAnalysis::saving synthesis...\n";
- if(_state == STATE_STOP) return;
+ // we don't need to synthesise
+ return;
- for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
-
- // cout << "StrobeAnalysis::synthesis FOR LOOP...\n";
-
- // cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
-
- if(_state == STATE_STOP) return;
-
- if(!image1.loadImage(_saved_filenames_analysis[i])){
- //couldn't load image
- // cout << "didn't load image" << endl;
- }
-
- if(image1.loadImage(_saved_filenames_analysis[i])){
- // cout << "LOADED image1!!!" << endl;
- if(image5.loadImage(_saved_filenames_analysis[i+1])){
-
- ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
-
- cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
- cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
-
- cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
- cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
-
- cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
- cvGrayDiff1.dilate();
- cvGrayDiff1.dilate();
- cvGrayDiff1.contrastStretch();
-
- /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
- string file_name;
-
- file_name = ofToString(_synth_save_cnt, 2)+"_StrobeAnalysis_"+ofToString(_run_cnt,2)+".jpg";
-
-
- //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ---->
- // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
-
-
- //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
- //ofImage image;
- //image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE);
-
- //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
- //image.setUseTexture(false);
-
- //image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height,OF_IMAGE_GRAYSCALE);
- //image.saveImage(_whole_file_path_synthesis+"/"+file_name);
-
- //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
-
-
-
- // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
- cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
-
- saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
- _synth_save_cnt++;
-
-
- }
- }
- }
-
- // _saved_filenames_synthesis has processed all the files in the analysis images folder
- while(!_RUN_DONE && _state != STATE_STOP)
- Thread::sleep(3);
+ /*
+
+ //cout << "IResponseAnalysis::saving synthesis...\n";
+ if(_state == STATE_STOP) return;
+
+ _RUN_DONE = false;
+
+ // _saved_filenames_synthesis has processed all the files in the analysis images folder
+ while(!_RUN_DONE && _state != STATE_STOP)
+ Thread::sleep(3);
+ */
}
void StrobeAnalysis::displayresults()
{
- for(float i=1;i<_saved_filenames_synthesis.size();i++){
+ for(float i=1;i<_saved_filenames_analysis.size();i++){
if(_state == STATE_STOP) return;
- // cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
+ //cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
while(!_image_shown){
Thread::sleep(2);
//cout << "!_image_shown" << endl;
}
- if(!image3.loadImage(_saved_filenames_synthesis[i])){
+ _show_image = false;
+
+
+ if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image
- // cout << "didn't load image" << endl;
+ cout << "didn't load image" << endl;
}
- if(image3.loadImage(_saved_filenames_synthesis[i])){
- image3.loadImage(_saved_filenames_synthesis[i]);
+ if(image1.loadImage(_saved_filenames_analysis[i])){
//cout << "_show_image = true;" << endl;
_show_image = true;
_image_shown = false;
}
- }
+ }
}
@@ -381,8 +306,6 @@ void StrobeAnalysis::draw()
case STATE_DISPLAY_RESULTS:
{
- // cout << "STATE_DISPLAY_RESULTS...\n" << endl;
-
if (_frame_cnt > 2)
{
_image_shown = true;
@@ -391,22 +314,48 @@ void StrobeAnalysis::draw()
_frame_cnt++;
+ ofEnableAlphaBlending();
+ glShadeModel(GL_SMOOTH);
+ glLineWidth(line_width);
+ glPointSize(point_size);
+ glEnable(GL_POINT_SMOOTH);
+
+ RefractiveIndex::cam.begin();
+
+ ofTranslate(tx, ty, tz);
+ ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
+ glScalef(1.5, 1, 1);
+
if (_show_image)
- {
- // cout << "_show_image...\n" << endl;
-
- ofEnableAlphaBlending();
-
- ofSetColor(255, 255, 255);
- image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR);
- image2.draw(0,0, ofGetWidth(), ofGetHeight());
-
- ofDisableAlphaBlending();
+ image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
+
+ image2.bind();
+
+ RefractiveIndex::_shader.begin();
+
+ RefractiveIndex::_shader.setUniform1i("algo", algo);
+ RefractiveIndex::_shader.setUniform1f("scale", scale);
+ RefractiveIndex::_shader.setUniform1i("tex0", 0);
+
+ switch (draw_style) {
+ case VERTS:
+ RefractiveIndex::_mesh_vbo.drawVertices();
+ break;
+ case WIRE:
+ RefractiveIndex::_mesh_vbo.drawWireframe();
+ break;
+ case FACE:
+ RefractiveIndex::_mesh_vbo.drawFaces();
+ break;
}
- // display results of the synthesis
- _RUN_DONE = true;
- break;
+ RefractiveIndex::_shader.end();
+
+ image2.unbind();
+
+ RefractiveIndex::cam.end();
+
+ break;
}
diff --git a/src/StrobeAnalysis.h b/src/StrobeAnalysis.h
index 90d64d2..68de7d7 100755
--- a/src/StrobeAnalysis.h
+++ b/src/StrobeAnalysis.h
@@ -41,31 +41,14 @@ protected:
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
bool _show_image, _image_shown;
+
ofImage image1;
ofImage image2;
- ofImage image3;
- ofImage image4;
- ofImage image5;
- ofImage image6;
- ofxCvColorImage cvColorImage1;
- ofxCvColorImage cvColorImage2;
- ofxCvColorImage cvColorImage3;
- ofxCvColorImage cvColorImage4;
- ofxCvColorImage cvColorImage5;
- ofxCvColorImage cvColorImage6;
-
- ofxCvGrayscaleImage cvGrayDiff1;
- ofxCvGrayscaleImage cvGrayDiff2;
-
- ofxCvGrayscaleImage cvGrayImage1;
- ofxCvGrayscaleImage cvGrayImage2;
- ofxCvGrayscaleImage cvGrayImage3;
- ofxCvGrayscaleImage cvGrayImage4;
-
- ofxCvContourFinder cvContourFinder1;
-
- //this is the temporary container to allow us to convert and save out greyscale images
- ofxCvColorImage cvConvertorImage;
+ int algo;
+ int scale;
+ int draw_style;
+ float line_width;
+ float point_size;
};