Skip to content

Commit

Permalink
Merge branch 'master' of github.com:smistad/FAST
Browse files Browse the repository at this point in the history
  • Loading branch information
smistad committed Jun 28, 2019
2 parents e3de14e + 289bdbe commit 96354ba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
3 changes: 1 addition & 2 deletions source/FAST/Algorithms/NeuralNetwork/NeuralNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,9 @@ Tensor::pointer NeuralNetwork::convertImagesToTensor(std::vector<Image::pointer>
);

// Read data directly into slice
device->getCommandQueue().enqueueReadBuffer(buffer, CL_FALSE, 0, sizeof(float) * size,
device->getCommandQueue().enqueueReadBuffer(buffer, CL_TRUE, 0, sizeof(float) * size,
values.get() + i*size);
}
device->getCommandQueue().finish();

auto tensor = Tensor::New();
tensor->create(std::move(values), shape);
Expand Down
1 change: 1 addition & 0 deletions source/FAST/Visualization/ImageRenderer/ImageRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void ImageRenderer::draw(Matrix4f perspectiveMatrix, Matrix4f viewingMatrix, flo
} else {
// Copy data from CL image to CPU
auto data = make_uninitialized_unique<float[]>(input->getWidth() * input->getHeight() * 4);
queue.finish();
queue.enqueueReadImage(
image,
CL_TRUE,
Expand Down
1 change: 1 addition & 0 deletions source/FAST/Visualization/LineRenderer/LineRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void LineRenderer::draw(Matrix4f perspectiveMatrix, Matrix4f viewingMatrix, floa
glEnable(GL_DEPTH_TEST);
}
deactivateShader();
glFinish(); // Fixes random crashes in OpenGL on NVIDIA windows due to some interaction with the text renderer. Suboptimal solution as glFinish is a blocking sync operation.
}

LineRenderer::LineRenderer() {
Expand Down
19 changes: 12 additions & 7 deletions source/FAST/Visualization/TextRenderer/TextRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QPainter>
#include <QApplication>
#include <FAST/Data/Text.hpp>
#include <QScreen>

namespace fast {

Expand All @@ -16,7 +17,7 @@ TextRenderer::TextRenderer() {
createInputPort<Text>(0);
mStyle = STYLE_NORMAL;
mPosition = POSITION_CENTER;
mFontSize = 18;
mFontSize = 28;
mColor = Color::Green();
createStringAttribute("position", "Text position", "Position of text in view (center/bottom_left/bottom_right/top_left/top_right)", "top_left");
createIntegerAttribute("font_size", "Font size", "Font size", mFontSize);
Expand Down Expand Up @@ -80,20 +81,23 @@ void TextRenderer::draw(Matrix4f perspectiveMatrix, Matrix4f viewingMatrix, floa
Text::access access = input->getAccess(ACCESS_READ);
std::string text = access->getData();


if(text.empty()) {
continue;
}

// Font setup
QColor color(mColor.getRedValue() * 255, mColor.getGreenValue() * 255, mColor.getBlueValue() * 255, 255);
QFont font = QApplication::font();
font.setPointSize(mFontSize);
font.setPixelSize(mFontSize);
if (mStyle == STYLE_BOLD) {
font.setBold(true);
} else if (mStyle == STYLE_ITALIC) {
font.setItalic(true);
}
QFontMetrics metrics(font);
const int width = metrics.boundingRect(QString(text.c_str())).width() + 10;
const int height = mFontSize + 5;

const int width = metrics.boundingRect(QString(text.c_str())).width();
const int height = metrics.boundingRect(QString(text.c_str())).height();
// create the QImage and draw txt into it
QImage textimg(width, height, QImage::Format_RGBA8888);
textimg.fill(QColor(0, 0, 0, 0));
Expand Down Expand Up @@ -168,7 +172,7 @@ void TextRenderer::draw(Matrix4f perspectiveMatrix, Matrix4f viewingMatrix, floa
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
activateShader();
for(auto it : mDataToRender) {
for(auto it : mTexturesToRender) {
const uint inputNr = it.first;
Affine3f transform = Affine3f::Identity();

Expand Down Expand Up @@ -222,6 +226,7 @@ void TextRenderer::draw(Matrix4f perspectiveMatrix, Matrix4f viewingMatrix, floa
}
glDisable(GL_BLEND);
deactivateShader();
glFinish(); // Fixes random crashes in OpenGL on NVIDIA windows due to some interaction with the line renderer. Suboptimal solution as glFinish is a blocking sync operation.
}

void TextRenderer::setFontSize(uint fontSize) {
Expand Down

0 comments on commit 96354ba

Please sign in to comment.