我编写简单的应用程序并且有raspicam库的问题。我打开了simpletest_raspicamm.cpp:
#include <ctime>
#include <fstream>
#include <iostream>
#include <raspicam/raspicam.h>
using namespace std;
int main ( int argc,char **argv ) {
raspicam::RaspiCam Camera; //Cmaera object
//Open camera
cout<<"Opening Camera..."<<endl;
if ( !Camera.open()) {cerr<<"Error opening camera"<<endl;return -1;}
//wait a while until camera stabilizes
cout<<"Sleeping for 3 secs"<<endl;
//capture
Camera.grab();
//allocate memory
unsigned char *data=new unsigned char[ Camera.getImageTypeSize ( raspicam::RASPICAM_FORMAT_RGB )];
//extract the image in rgb format
Camera.retrieve ( data,raspicam::RASPICAM_FORMAT_RGB );//get camera image
//save
std::ofstream outFile ( "raspicam_image.ppm",std::ios::binary );
outFile<<"P6\n"<<Camera.getWidth() <<" "<<Camera.getHeight() <<" 255\n";
outFile.write ( ( char* ) data, Camera.getImageTypeSize ( raspicam::RASPICAM_FORMAT_RGB ) );
cout<<"Image saved at raspicam_image.ppm"<<endl;
//free resrources
delete data;
return 0;
}
控制台让我回头: /home/pi/Desktop/raspicam-0.0.7/src/private/private_impl.cpp:171:Private_Impl :: retrieve类型不是RASPICAM_FORMAT_IGNORE,因为它应该是 图像保存在raspicam_image.ppm
我使用raspicam 0.0.7我试图使用所有其他版本和nothings更改。我编译使用命令:
g++ -ggdb -o `basename server.cpp .cpp` server1.cpp -I/usr/local/include/ - lraspicam -L/opt/vc/lib
我尝试过使用Camera.setFormat(raspicam :: RASPICAM_FORMAT_IGNORE)并且不知道如何修复它。我在raspberry pi 2上工作,但在rpi3上一切正常。
答案 0 :(得分:0)
看来 retrieve()
的界面从 v0.0.5 according to the comments in the header file.
基本上这个参数现在没用了,可以总是设置为 RASPICAM_FORMAT_IGNORE
,或者只是留空让 C++ 默认参数启动。你看到的警告基本上什么都不做,不会对性能。
现在可以通过 independent function
设置格式void setFormat ( RASPICAM_FORMAT fmt );