Add entities for convolutional layers.
This commit is contained in:
@@ -88,6 +88,6 @@ void FlatLayerVisualisation::render()
|
|||||||
glColorPointer(3, GL_FLOAT, 0, colorBuffer.get());
|
glColorPointer(3, GL_FLOAT, 0, colorBuffer.get());
|
||||||
glDrawElements(GL_TRIANGLES, faceCount * 3, GL_UNSIGNED_INT, indexBuffer.get());
|
glDrawElements(GL_TRIANGLES, faceCount * 3, GL_UNSIGNED_INT, indexBuffer.get());
|
||||||
|
|
||||||
glDisable(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisable(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ MultiImageVisualisation::MultiImageVisualisation(const fmri::LayerData &layer)
|
|||||||
width = dimensions[2],
|
width = dimensions[2],
|
||||||
height = dimensions[3];
|
height = dimensions[3];
|
||||||
|
|
||||||
|
CHECK_EQ(1, images) << "Only single input image is supported" << endl;
|
||||||
|
|
||||||
|
vertexBuffer = std::make_unique<float[]>(channels * 12);
|
||||||
|
|
||||||
auto dataPtr = layer.data();
|
auto dataPtr = layer.data();
|
||||||
for (auto i = 0; i < images; ++i) {
|
for (auto i = 0; i < images; ++i) {
|
||||||
for (auto j = 0; j < channels; ++j) {
|
for (auto j = 0; j < channels; ++j) {
|
||||||
@@ -22,6 +26,36 @@ MultiImageVisualisation::MultiImageVisualisation(const fmri::LayerData &layer)
|
|||||||
dataPtr += width * height;
|
dataPtr += width * height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int columns = sqrt(channels);
|
||||||
|
while (channels % columns) columns++;
|
||||||
|
int rows = channels / columns;
|
||||||
|
|
||||||
|
// Create the quads for the images.
|
||||||
|
int r = 0, c = 0;
|
||||||
|
int v = 0;
|
||||||
|
for (int i = 0; i < channels; ++i) {
|
||||||
|
vertexBuffer[v++] = 0;
|
||||||
|
vertexBuffer[v++] = 0 + 3 * r;
|
||||||
|
vertexBuffer[v++] = 0 - 3 * c;
|
||||||
|
|
||||||
|
vertexBuffer[v++] = 0;
|
||||||
|
vertexBuffer[v++] = 2 + 3 * r;
|
||||||
|
vertexBuffer[v++] = 0 - 3 * c;
|
||||||
|
|
||||||
|
vertexBuffer[v++] = 0;
|
||||||
|
vertexBuffer[v++] = 2 + 3 * r;
|
||||||
|
vertexBuffer[v++] = 2 - 3 * c;
|
||||||
|
|
||||||
|
vertexBuffer[v++] = 0;
|
||||||
|
vertexBuffer[v++] = 0 + 3 * r;
|
||||||
|
vertexBuffer[v++] = 2 - 3 * c;
|
||||||
|
|
||||||
|
if (++c >= columns) {
|
||||||
|
c = 0;
|
||||||
|
++r;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiImageVisualisation::~MultiImageVisualisation()
|
MultiImageVisualisation::~MultiImageVisualisation()
|
||||||
@@ -33,5 +67,9 @@ MultiImageVisualisation::~MultiImageVisualisation()
|
|||||||
|
|
||||||
void MultiImageVisualisation::render()
|
void MultiImageVisualisation::render()
|
||||||
{
|
{
|
||||||
// TODO: do something.
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glColor3f(1, 1, 1);
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, vertexBuffer.get());
|
||||||
|
glDrawArrays(GL_QUADS, 0, 4 * textureReferences.size());
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include "LayerVisualisation.hpp"
|
#include "LayerVisualisation.hpp"
|
||||||
#include "LayerData.hpp"
|
#include "LayerData.hpp"
|
||||||
|
|
||||||
@@ -17,5 +18,6 @@ namespace fmri
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::pair<int, int>, GLuint> textureReferences;
|
std::map<std::pair<int, int>, GLuint> textureReferences;
|
||||||
|
std::unique_ptr<float[]> vertexBuffer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user