200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > Gtk-Message: 14:47:21.541: Failed to load module “canberra-gtk-module“ 的处理方法

Gtk-Message: 14:47:21.541: Failed to load module “canberra-gtk-module“ 的处理方法

时间:2020-11-13 13:15:43

相关推荐

Gtk-Message: 14:47:21.541: Failed to load module “canberra-gtk-module“ 的处理方法

最近研究读取Elekta加速器XVI产生的his格式的数据读取,利用OpenCV 进行显示时,发现了一个错误(Ubuntu20)如下:Gtk-Message: 14:47:21.541: Failed to load module "canberra-gtk-module"

这个提示可能是缺少canberra-gtk-module模块没有安装。作为新一代青年,上网搜索才是解决方法。

上网搜索得知,我的判断是对的,于是

sudo apt-get install libcanberra-gtk*

神奇的是,我的显示模式也瞬间变得清晰了,太神奇了。

可能会有小伙伴们想知道怎样读取HIS格式的文件了,告诉大家,很简单的。(文件在这里)文件的大小为524388个字节,前100个字节是文件的文件头信息,

28672 #文件的ID

68 #文件头大小

0 #版本

100 #

8 #文件的大小,这里使用了4个字节表示,读取错误

32 #图像信息的大小

1 #X方向坐上

1 # Y方向,左上

512 #X右下 也可以理解成row

512 #Y右下 column

1 # 不解释了,后面的没有用了

0

0

0

0

0

4 #使用16位数据进行存储

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

61784

65446

46682

65504

64609

65525

65534

65535

41560

65455

1888

638

46661

65455

1888

638

从第101个字节开始,到512×512×2结束,是数据部分。

代码如下:

#include <iostream>

#include <opencv2/opencv.hpp>

#include <fstream>

#include <vector>

#include <string>

using namespace std;

int main(int,char**)

{

string fileName="../data/test.his";

fstream reader;

reader.open(fileName.c_str(),ios::in|ios::binary); //read file as binary

if(!reader.is_open()){

cout<<"read file failed."<<endl;

return -1;

}

reader.seekg(0,ios::end);

cout<<"File size is: "<<reader.tellg()<<endl; // determin the file size.

reader.seekg(0,ios::beg); //pointer come back to the initial position.

vector<unsigned short> header;

char buffer[100];

reader.read(buffer,100); // read 1 byte every time.

for(int i=0;i<50;i++){

unsigned short p=buffer[2*i+1]<<8|buffer[2*i+0]; //little endiant

header.push_back(p);

}

for(vector<unsigned short>::iterator it=header.begin();it!=header.end();++it){

cout<<*it<<endl;

} //display the header information

int row,col;

row=header[8];

col=header[9];

// Reade the pixel data

reader.seekg(100,ios::beg);

int m=512*512;

char data[m*2];

reader.read(data,m*2); //read the pixel data

unsigned short pixel[m];

for(int i=0;i<m;++i){

pixel[i]=data[2*i+1]<<8|data[2*i+0]; //little endiant

}

reader.close();

// display the image using OpenCV

cv::Mat image=cv::Mat(col,row,CV_16UC1,pixel);

cv::normalize(image,image,0,255,cv::NORM_MINMAX,CV_8UC1);

cv::imshow("",image);

cv::waitKey(0);

return 0;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。