/** * Cam * Copyright (C) 2021 Carl Klemm * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 3 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include "log.h" #include "uvoscam.h" #define VERSION "0.1" using namespace cam; static std::string filename; void listDevices() { std::vector cameras = Camera::getAvailableCameras(); size_t i = 0; for(auto camera : cameras) std::cout< "< tokenize(const std::string& in, char delim = ' ') { std::vector vect; std::stringstream ss(in); for(std::string token; std::getline(ss, token, delim);) vect.push_back(token); return vect; } int main(int argc, char* argv[]) { Camera camera(callback); Log::level = Log::DEBUG; Log(Log::INFO)<<"UVOS Camera capture program "< "; std::string line; std::getline(std::cin, line); std::vector tokens = tokenize(line); if(!tokens.empty()) { if(tokens[0].find("help") != std::string::npos) help(); else if(tokens[0].find("exit") != std::string::npos || tokens[0].find("quit") != std::string::npos) break; else if(tokens[0].find("list") != std::string::npos) listDevices(); else if(tokens[0].find("open") != std::string::npos || tokens[0] == "o") { if(tokens.size() > 1) { size_t index = std::stoul(tokens[1]); if(index < Camera::getAvailableCameras().size()) { camera.openCamera(index); if(camera.isOpen()) { camera.setAcquisitionMode(Camera::MODE_SINGLE); camera.setBayerMode(Camera::BAYER_GREEN); camera.setTriggerMode(Camera::TRIGGER_SOFTWARE); camera.startAcquisition(); } } else { std::cout<<"Index out of range\n"; } } } else if(tokens[0].find("capture") != std::string::npos || tokens[0] == "c") { if(camera.isOpen()) { if(tokens.size() > 1) filename = tokens[1] + ".png"; else filename = "testimg.png"; camera.startAcquisition(); camera.trigger(); } else { std::cout<<"Camera not open\n"; } } else if(tokens[0].find("exposure") != std::string::npos || tokens[0] == "e") { if(camera.isOpen()) { if(tokens.size() > 1) { if(!camera.setExposureTime(atof(tokens[1].c_str())*1000000.0)) std::cout<<"setting exposure time failed\n"; } else std::cout<<"Exposure time: "< 1) { if(!camera.setGain(atof(tokens[1].c_str()))) std::cout<<"setting exposure time failed\n"; } else std::cout<<"Gain: "<