Save video
This commit is contained in:
parent
397e6fe331
commit
c40b69ebe2
@ -104,16 +104,26 @@ LFR_StateMachine::LFR_StateMachine():
|
|||||||
currentState = &State::Idle::getInstance();
|
currentState = &State::Idle::getInstance();
|
||||||
currentState->enter(this);
|
currentState->enter(this);
|
||||||
|
|
||||||
//Start the permanent loop
|
cv::VideoWriter writer = cv::VideoWriter("video_200.avi", cv::VideoWriter::fourcc('M','J','P','G'), 4.0, cv::Size(videoWidth, videoHeight), true);
|
||||||
char input;
|
|
||||||
std::cout << "press q to quit" << std::endl;
|
auto t_start = std::chrono::high_resolution_clock::now();
|
||||||
std::cin >> input;
|
auto t_end = std::chrono::high_resolution_clock::now();
|
||||||
std::cout << "binned" << std::endl;
|
double dur = std::chrono::duration<double, std::milli>(t_end-t_start).count();
|
||||||
while (input != 'q')
|
|
||||||
|
while(dur < 60000)
|
||||||
{
|
{
|
||||||
std::cin >> input;
|
t_end = std::chrono::high_resolution_clock::now();
|
||||||
std::cout << "binned" << std::endl;
|
dur = std::chrono::duration<double, std::milli>(t_end-t_start).count();
|
||||||
|
{
|
||||||
|
this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
|
std::unique_lock<std::mutex> lock(imgMutex);
|
||||||
|
if(!this->image.empty())
|
||||||
|
{
|
||||||
|
writer.write(this->image);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.release();
|
||||||
std::cout << "Exiting central" << std::endl;
|
std::cout << "Exiting central" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +156,10 @@ void LFR_StateMachine::enterAutonomous()
|
|||||||
double delta = static_cast<double>(deltaMs) / 1000.0;
|
double delta = static_cast<double>(deltaMs) / 1000.0;
|
||||||
double frameRate = 1.0 / static_cast<double>(delta);*/
|
double frameRate = 1.0 / static_cast<double>(delta);*/
|
||||||
double frameRate = -1.0;
|
double frameRate = -1.0;
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(imgMutex);
|
||||||
|
image = result.rawImage;
|
||||||
|
}
|
||||||
|
|
||||||
if (result.validLane)
|
if (result.validLane)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ class LFR_StateMachine
|
|||||||
const int videoHeight = 720;
|
const int videoHeight = 720;
|
||||||
const int videoWidth = 1280;
|
const int videoWidth = 1280;
|
||||||
const int gaussKernelSize = 11;
|
const int gaussKernelSize = 11;
|
||||||
const double maxSpeed = 0.5;
|
const double maxSpeed = 0.20;
|
||||||
|
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
|
||||||
@ -24,6 +24,9 @@ class LFR_StateMachine
|
|||||||
LFR_UART uartCommunicator;
|
LFR_UART uartCommunicator;
|
||||||
LFR_Socket socket;
|
LFR_Socket socket;
|
||||||
|
|
||||||
|
std::mutex imgMutex;
|
||||||
|
Mat image;
|
||||||
|
|
||||||
vector<string> split (string s, string delimiter) const;
|
vector<string> split (string s, string delimiter) const;
|
||||||
void sanitize (string& s) const;
|
void sanitize (string& s) const;
|
||||||
bool checkStringValidity (const std::vector<std::string>& s) const;
|
bool checkStringValidity (const std::vector<std::string>& s) const;
|
||||||
@ -36,3 +39,5 @@ public:
|
|||||||
inline LFR_IState* getCurrentState() const {return currentState;}
|
inline LFR_IState* getCurrentState() const {return currentState;}
|
||||||
void setState(LFR_IState& newState);
|
void setState(LFR_IState& newState);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user