我正在从事使用 Insta360 One RS 相机的项目。 这是存储库的链接text.
按照这个存储库的说明,我可以找到我的相机连接到 USB:
Bus 001 Device 037: ID 2e1a:0002 Arashi Vision Insta360 ONERS
在提供的SDK下有四个文件夹: |---bin | |---可执行CameraSDKTest |---包括 | |---带.h的文件夹 |---例子 | |---main.cc |---lib | |--- .so 文件
我正在使用: Ubuntu:20.04 g++: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 VSCode:版本:1.77.3
主要问题是无法编译main.cc文件生成像现有的可执行文件到bin文件夹中。 当我尝试点击编译时,出现错误:
fatal error: camera.h: No such file or directory
3 | #include "camera.h"
| ^~~~~~~~~~
compilation terminated.
c_cpp_properties.json 被分配到 include 文件夹所在的本地。
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/ricardo/LinuxSDK20221219/LinuxSDK20221219/CameraSDK20220909(Linux)/cameradk_linux_20220909/include/camera",
"/home/ricardo/LinuxSDK20221219/LinuxSDK20221219/CameraSDK20220909(Linux)/cameradk_linux_20220909/include/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
这里是main.cc
include <iostream>
#include <thread>
#include "camera.h"
#include "photography_settings.h"
#include "device_discovery.h"
#include <regex>
class TestStreamDelegate : public ins_camera::StreamDelegate
{
public:
TestStreamDelegate()
{
file1_ = fopen("./01.h264", "wb");
file2_ = fopen("./02.h264", "wb");
}
~TestStreamDelegate()
{
fclose(file1_);
fclose(file2_);
}
void OnAudioData(const uint8_t *data, size_t size, int64_t timestamp) override
{
std::cout << "on audio data:" << std::endl;
}
void OnVideoData(const uint8_t *data, size_t size, int64_t timestamp, uint8_t streamType, int stream_index = 0) override
{
// std::cout << "on video frame:" << size << ";" << timestamp << std::endl;
if (stream_index == 0)
{
fwrite(data, sizeof(uint8_t), size, file1_);
}
if (stream_index == 1)
{
fwrite(data, sizeof(uint8_t), size, file2_);
}
}
void OnGyroData(const std::vector<ins_camera::GyroData> &data) override
{
// for (auto& gyro : data) {
// if (gyro.timestamp - last_timestamp > 2) {
// fprintf(file1_, "timestamp:%lld package_size = %d offtimestamp = %lld gyro:[%f %f %f] accel:[%f %f %f]\n", gyro.timestamp, data.size(), gyro.timestamp - last_timestamp, gyro.gx, gyro.gy, gyro.gz, gyro.ax, gyro.ay, gyro.az);
// }
// last_timestamp = gyro.timestamp;
// }
}
void OnExposureData(const ins_camera::ExposureData &data) override
{
// fprintf(file2_, "timestamp:%lld shutter_speed_s:%f\n", data.timestamp, data.exposure_time);
}
private:
FILE *file1_;
FILE *file2_;
int64_t last_timestamp = 0;
};
int main(int argc, char *argv[])
{
std::cout << "begin open camera" << std::endl;
ins_camera::DeviceDiscovery discovery;
auto list = discovery.GetAvailableDevices();
for (int i = 0; i < list.size(); ++i)
{
auto desc = list[i];
std::cout << "serial:" << desc.serial_number << "\t"
<< "camera type:" << int(desc.camera_type) << "\t"
<< "lens type:" << int(desc.lens_type) << std::endl;
}
if (list.size() <= 0)
{
std::cerr << "no device found." << std::endl;
return -1;
}
std::shared_ptr<ins_camera::Camera> cam = std::make_shared<ins_camera::Camera>(list[0].info);
// ins_camera::Camera cam(list[0].info);
if (!cam->Open())
{
std::cerr << "failed to open camera" << std::endl;
return -1;
}
std::cout << "http base url:" << cam->GetHttpBaseUrl() << std::endl;
std::shared_ptr<ins_camera::StreamDelegate> delegate = std::make_shared<TestStreamDelegate>();
cam->SetStreamDelegate(delegate);
discovery.FreeDeviceDescriptors(list);
std::cout << "Succeed to open camera..." << std::endl;
std::cout << "Usage" << std::endl;
std::cout << "1: take photo" << std::endl;
std::cout << "2: get serial number" << std::endl;
std::cout << "3: get file list(only video and photo)" << std::endl;
std::cout << "4: delete file" << std::endl;
std::cout << "5: download file" << std::endl;
std::cout << "6: start recording" << std::endl;
std::cout << "7: stop recording" << std::endl;
std::cout << "8: test set exposure settings:" << std::endl;
std::cout << "9: test set capture settings:" << std::endl;
std::cout << "10: start preview live streaming:" << std::endl;
std::cout << "11: stop preview live streaming:" << std::endl;
std::cout << "16: get uuid " << std::endl;
std::cout << "17: test take photo and download " << std::endl;
std::cout << "18: get current capture status " << std::endl;
std::cout << "19: start timelapse " << std::endl;
std::cout << "20: stop timelapse " << std::endl;
std::cout << "21: get batty " << std::endl;
std::cout << "22: get storage info " << std::endl;
std::cout << "0: exit" << std::endl;
auto camera_type = cam->GetCameraType();
auto start = time(NULL);
cam->SyncLocalTimeToCamera(start);
int option;
while (true)
{
std::cout << "please enter index: ";
std::cin >> option;
if (option < 0 || option > 30)
{
std::cout << "Invalid index" << std::endl;
continue;
}
if (option == 0)
{
break;
}
// take photo
if (option == 1)
{
const auto url = cam->TakePhoto();
if (!url.IsSingleOrigin() || url.Empty())
{
std::cout << "failed to take picture" << std::endl;
break;
}
std::cout << "Take picture done: " << url.GetSingleOrigin() << std::endl;
}
// get serial number from camera
if (option == 2)
{
const auto serial_number = cam->GetSerialNumber();
if (serial_number.empty())
{
std::cout << "failed to get serial number" << std::endl;
break;
}
std::cout << "serial number: " << serial_number << std::endl;
}
// get camera file list(only video and photo for now)
if (option == 3)
{
const auto file_list = cam->GetCameraFilesList();
for (const auto &file : file_list)
{
std::cout << "File: " << file << std::endl;
}
}
// delete file from camera
if (option == 4)
{
std::string file_to_delete;
std::cout << "please input full file path to delete: ";
std::cin >> file_to_delete;
const auto ret = cam->DeleteCameraFile(file_to_delete);
if (ret)
{
std::cout << "Deletion succeed" << std::endl;
}
}
// download file from camera
if (option == 5)
{
std::string file_to_download;
std::string file_to_save;
std::cout << "please input full file path to download: ";
std::cin >> file_to_download;
std::cout << "please input full file path to save: ";
std::cin >> file_to_save;
const auto ret = cam->DownloadCameraFile(file_to_download,
file_to_save);
if (ret)
{
std::cout << "Download " << file_to_download << " succeed!!!" << std::endl;
}
else
{
std::cout << "Download " << file_to_download << " failed!!!" << std::endl;
}
}
if (option == 6)
{
if (!cam->SetVideoCaptureParams({ins_camera::VideoResolution::RES_3040_3040P24,
1024 * 1024 * 10},
ins_camera::CameraFunctionMode::FUNCTION_MODE_NORMAL_VIDEO))
{
std::cerr << "failed to set capture settings." << std::endl;
}
else
{
auto ret = cam->StartRecording();
if (ret)
{
std::cerr << "success!" << std::endl;
}
else
{
std::cerr << "failed to start recording" << std::endl;
}
}
}
if (option == 7)
{
auto url = cam->StopRecording();
if (url.Empty())
{
std::cerr << "stop recording failed" << std::endl;
continue;
}
auto &origins = url.OriginUrls();
std::cout << "stop recording success" << std::endl;
for (auto &origin_url : origins)
{
std::cout << "url:" << origin_url << std::endl;
}
}
if (option == 8)
{
auto exposure_settings = cam->GetExposureSettings(ins_camera::CameraFunctionMode::FUNCTION_MODE_NORMAL_IMAGE);
if (exposure_settings)
{
std::cout << "EVBias : " << exposure_settings->EVBias() << std::endl;
std::cout << "ISO : " << exposure_settings->Iso() << std::endl;
std::cout << "speed : " << exposure_settings->ShutterSpeed() << std::endl;
}
int bias;
std::cout << "please enter EVBIOS: ";
std::cin >> bias;
auto exposure = std::make_shared<ins_camera::ExposureSettings>();
auto exposure_mode = ins_camera::PhotographyOptions_ExposureMode::PhotographyOptions_ExposureOptions_Program_AUTO;
if (camera_type == ins_camera::CameraType::Insta360X3)
{
exposure_mode = ins_camera::PhotographyOptions_ExposureMode::PhotographyOptions_ExposureOptions_Program_FULL_AUTO;
}
exposure->SetExposureMode(exposure_mode);
exposure->SetEVBias(bias); // range -80 ~ 80, default 0, step 1
exposure->SetIso(800);
exposure->SetShutterSpeed(1.0 / 120.0);
auto ret = cam->SetExposureSettings(ins_camera::CameraFunctionMode::FUNCTION_MODE_NORMAL_IMAGE, exposure);
if (ret)
{
auto exposure_settings = cam->GetExposureSettings(ins_camera::CameraFunctionMode::FUNCTION_MODE_NORMAL_IMAGE);
std::cout << "success! ISO " << exposure_settings->Iso() << ", WB = " << exposure_settings->ShutterSpeed() << ", ExposureMode = " << exposure_settings->ExposureMode() << std::endl;
}
else
{
std::cerr << "failed to set exposure" << std::endl;
}
}
if (option == 9)
{
auto settings = std::make_shared<ins_camera::CaptureSettings>();
settings->SetValue(ins_camera::CaptureSettings::CaptureSettings_Saturation, 0);
settings->SetWhiteBalance(ins_camera::PhotographyOptions_WhiteBalance_WB_4000K);
settings->SetValue(ins_camera::CaptureSettings::CaptureSettings_Brightness, 100);
auto ret = cam->SetCaptureSettings(ins_camera::CameraFunctionMode::FUNCTION_MODE_NORMAL_IMAGE, settings);
if (ret)
{
auto capture_settings = cam->GetCaptureSettings(ins_camera::CameraFunctionMode::FUNCTION_MODE_NORMAL_IMAGE);
std::cout << "success!" << std::endl;
}
else
{
std::cerr << "failed to set capture settings" << std::endl;
}
}
if (option == 10)
{
ins_camera::LiveStreamParam param;
param.video_resolution = ins_camera::VideoResolution::RES_2560_1280P30;
param.lrv_video_resulution = ins_camera::VideoResolution::RES_1152_768P30;
param.video_bitrate = 1024 * 1024 / 2;
param.enable_audio = false;
param.using_lrv = true;
if (cam->StartLiveStreaming(param))
{
std::cout << "successfully started live stream" << std::endl;
}
}
if (option == 11)
{
if (cam->StopLiveStreaming())
{
std::cout << "success!" << std::endl;
}
else
{
std::cerr << "failed to stop live." << std::endl;
}
}
if (option == 16)
{
const auto str_uuid = cam->GetCameraUUID();
if (str_uuid.empty())
{
std::cerr << "failed to get uuid" << std::endl;
return -1;
}
std::cout << "uuid : " << str_uuid << std::endl;
}
if (option == 17)
{
int test_cout = 100;
int test = -1;
while (test_cout-- != 0)
{
const auto url = cam->TakePhoto();
if (!url.IsSingleOrigin() || url.Empty())
{
std::cout << "failed to take picture" << std::endl;
return -1;
}
std::string download_url = url.GetSingleOrigin();
std::string save_path = "D:/testImage" + download_url;
const auto ret = cam->DownloadCameraFile(download_url, save_path);
if (ret)
{
std::cout << "Download " << download_url << " succeed!!!" << std::endl;
}
else
{
std::cout << "Download " << download_url << " failed!!!" << std::endl;
}
}
cam->Close();
return 0;
}
if (option == 18)
{
auto ret = cam->GetCaptureCurrentStatus();
if (ret == ins_camera::CaptureStatus::NOT_CAPTURE)
{
std::cout << "current statue : not capture" << std::endl;
;
}
else
{
std::cout << "current statue : capture" << std::endl;
}
}
if (option == 19)
{
ins_camera::TimelapseParam param;
// mode 是你相机所支持的模式
param.mode = ins_camera::CameraTimelapseMode::MOBILE_TIMELAPSE_VIDEO;
param.duration = -1;
param.lapseTime = 3000;
param.accelerate_fequency = 5;
if (!cam->SetTimeLapseOption(param))
{
std::cerr << "failed to set capture settings." << std::endl;
}
else
{
auto ret = cam->StartTimeLapse(param.mode);
if (ret)
{
std::cerr << "success!" << std::endl;
}
else
{
std::cerr << "failed to start timelapse" << std::endl;
}
}
}
if (option == 20)
{
auto url = cam->StopTimeLapse(ins_camera::CameraTimelapseMode::MOBILE_TIMELAPSE_VIDEO);
if (url.Empty())
{
std::cerr << "stop timelapse failed" << std::endl;
continue;
}
auto &origins = url.OriginUrls();
std::cout << "stop timelapse success" << std::endl;
for (auto &origin_url : origins)
{
std::cout << "url:" << origin_url << std::endl;
}
}
if (option == 21)
{
if (!cam->IsConnected())
{
std::cout << "device is offline" << std::endl;
break;
}
ins_camera::BatteryStatus status;
bool ret = cam->GetBatteryStatus(status);
if (!ret)
{
std::cerr << "GetBatteryStatus failed" << std::endl;
continue;
}
std::cout << "PowerType : " << status.power_type << std::endl;
std::cout << "battery_level : " << status.battery_level << std::endl;
std::cout << "battery_scale : " << status.battery_scale << std::endl;
}
if (option == 22)
{
ins_camera::StorageStatus status;
bool ret = cam->GetStorageState(status);
if (!ret)
{
std::cerr << "GetBatteryStatus failed" << std::endl;
continue;
}
std::cout << "free_space : " << status.free_space << std::endl;
std::cout << "total_space : " << status.total_space << std::endl;
std::cout << "state : " << status.state << std::endl;
}
if (option == 30)
{
const auto file_list = cam->GetCameraFilesList();
for (const auto &file : file_list)
{
std::string save_path = "D:/testImage" + file;
int ret = cam->DownloadCameraFile(file, save_path);
if (ret)
{
std::cout << "Download " << file << " succeed!!!" << std::endl;
}
else
{
std::cout << "Download " << file << " failed!!!" << std::endl;
}
}
}
if (option == 31)
{
const auto file_list = cam->GetCameraFilesList();
for (const auto &file : file_list)
{
const auto ret = cam->DeleteCameraFile(file);
if (ret)
{
std::cout << file << " Deletion succeed" << std::endl;
}
}
}
}
cam->Close();
return 0;
}
我尝试手动编译
g++ -L/path-to-.h_HEADER/include/camera main.cc
并得到错误
bash: syntax error near unexpected token
('
`