提交 f22d1e3a 编写于 作者: Z ZeusJupiter 提交者: fengqikai1414

Modules: fix camera issue of cyber_visualizer

上级 0b317977
......@@ -92,7 +92,7 @@ struct MainWindow::VideoImgProxy {
QMutex reader_mutex_;
std::shared_ptr<Texture> dynamic_texture_;
CyberChannReader<apollo::drivers::CompressedImage>* channel_reader_;
CyberChannReader<apollo::drivers::Image>* channel_reader_;
};
MainWindow::MainWindow(QWidget* parent)
......@@ -692,25 +692,20 @@ void MainWindow::PlayRenderableObject(bool b) {
}
void MainWindow::ImageReaderCallback(
const std::shared_ptr<const apollo::drivers::CompressedImage>& imgData,
const std::shared_ptr<const apollo::drivers::Image>& imgData,
VideoImgProxy* theVideoImgProxy) {
theVideoImgProxy->reader_mutex_.lock();
if (theVideoImgProxy->dynamic_texture_ != nullptr && imgData != nullptr) {
QImage img;
if (img.loadFromData((const unsigned char*)(imgData->data().c_str()),
imgData->ByteSize())) {
if (theVideoImgProxy->dynamic_texture_->UpdateData(img)) {
theVideoImgProxy->video_image_viewer_.SetupDynamicTexture(
theVideoImgProxy->dynamic_texture_);
} else {
std::cerr << "--------Cannot update dynamic Texture Data--------"
<< std::endl;
}
if (theVideoImgProxy->dynamic_texture_->UpdateData(imgData)) {
theVideoImgProxy->video_image_viewer_.SetupDynamicTexture(
theVideoImgProxy->dynamic_texture_);
} else {
std::cerr
<< "-----------Cannot load compressed image from data with QImage"
<< std::endl;
std::cerr << "--------Cannot update dynamic Texture Data--------"
<< std::endl;
}
} else {
std::cerr << "----Dynamic Texture is nullptr or apollo.drivers.Image is nullptr"
<< std::endl;
}
theVideoImgProxy->reader_mutex_.unlock();
}
......@@ -735,7 +730,7 @@ void MainWindow::DoPlayVideoImage(bool b, VideoImgProxy* theVideoImg) {
if (!theVideoImg->channel_reader_) {
theVideoImg->channel_reader_ =
new CyberChannReader<apollo::drivers::CompressedImage>();
new CyberChannReader<apollo::drivers::Image>();
if (!theVideoImg->channel_reader_) {
QMessageBox::warning(this, tr("Create Cybertron Channel Reader"),
......@@ -745,10 +740,11 @@ void MainWindow::DoPlayVideoImage(bool b, VideoImgProxy* theVideoImg) {
return;
}
auto videoCallback = [this, theVideoImg](
const std::shared_ptr<apollo::drivers::CompressedImage>& pdata) {
this->ImageReaderCallback(pdata, theVideoImg);
};
auto videoCallback =
[this,
theVideoImg](const std::shared_ptr<apollo::drivers::Image>& pdata) {
this->ImageReaderCallback(pdata, theVideoImg);
};
if (!theVideoImg->channel_reader_->InstallCallbackAndOpen(
videoCallback, theVideoImg->channel_name_combobox_.currentText()
......
......@@ -96,7 +96,7 @@ class MainWindow : public QMainWindow {
void PointCloudReaderCallback(
const std::shared_ptr<const apollo::drivers::PointCloud>& pdata);
void ImageReaderCallback(
const std::shared_ptr<const apollo::drivers::CompressedImage>& imgData,
const std::shared_ptr<const apollo::drivers::Image>& imgData,
VideoImgProxy* proxy);
void InsertAllChannelNames(void);
......
......@@ -21,8 +21,7 @@ out vec4 FragColor;
uniform sampler2D texture;
void main(void)
{
void main(void) {
vec4 v4 = texture2D(texture, TexCoord);
FragColor = vec4(v4.bgra);
FragColor = vec4(v4.rgb, 1.0);
}
......@@ -50,3 +50,28 @@ bool Texture::UpdateData(const QImage &img) {
texture_format_ = GL_RGBA;
return true;
}
bool Texture::UpdateData(const std::shared_ptr<const apollo::drivers::Image>& imgData){
std::size_t imgSize = imgData->data().size();
if (static_cast<std::size_t>(data_size_) < imgSize) {
if (!data_) {
delete[] data_;
}
data_ = new GLubyte[imgSize];
if (data_ == nullptr) {
data_size_ = 0;
return false;
}
data_size_ = imgSize;
is_size_changed_ = true;
}
memcpy(data_, imgData->data().c_str(), imgSize);
is_dirty_ = true;
image_width_ = imgData->width();
image_height_ = imgData->height();
texture_format_ = GL_RGB;
return true;
}
......@@ -44,6 +44,7 @@ class Texture {
GLsizei data_size(void) const { return data_size_; }
bool UpdateData(const QImage& img);
bool UpdateData(const std::shared_ptr<const apollo::drivers::Image>&);
const GLubyte* data(void) const { return data_; }
private:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册