support camera frame data pipeline ?
lix19937 opened this issue · comments
It does not support data-driven pipeline or not ? like camera frame data pipeline, camera keep a fixed frame rate, see #148.
If Graph Processing Pipeline support, how to use ? Thanks !
Graph pipelining allow users to schedule a graph multiple times, without having to wait for a graph execution to complete. Each such execution of the graph operates on different input or output references.
// follow is my code, run the taskflow iteratively with changing frame data
I think follow is not right.
#include <taskflow/taskflow.hpp>
int main(){
tf::Executor executor;
tf::Taskflow taskflow("camera pipeline");
// camera frame data
void *data_in{nullptr};
// out of node(task)
A_OUT a_out;
B_OUT b_out;
C_OUT c_out;
// create a task and attach it the camera data
auto NodeA = taskflow.placeholder();
NodeA.data(&data_in).work([NodeA, &a_out](){
// task impl api
// ...
});
auto NodeB = taskflow.placeholder();
NodeB.data(&a_out).work([NodeB, &b_out](){
// task impl api
// ...
});
auto NodeC = taskflow.placeholder();
NodeB.data(&b_out).work([NodeC, &c_out](){
// task impl api
// ...
});
NodeA.precede(NodeB);
NodeB.precede(NodeC);
// iteratively with changing camera data
while(1){
// get camera data here, define in other
GetCameraData(data_in);
// here maybe wrong, here next frame`s should wait last frame process done !!!
executor.run(taskflow).wait();
}
return 0;
}
DFS Scheduler always process full Node.
A fixed Process is below:
// define a frame processing ITERATION ie. 10Hz
define ITERATION 100
while(True){
while(pipline.alive() || pipline.ready()){
auto start = std::chrono::high_resolution_clock::now();
auto iteration = std::chrono::high_resolution_clock::now();
if(pipline.timeout()){
break;
}
if(data.error() || process.error()){
break;
}
auto duration_ = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::high_resolution_clock::now() - iteration)
.count();
// Calculate the remaining time to wait
auto remainingTime = std::chrono::microseconds(ITERATION) -
std::chrono::microseconds(duration_);
if (remainingTime.count() > 0)
{
std::this_thread::sleep_for(remainingTime);
}
}
}
You should split your pipline, example creating a chain for three pipline. Giving each pipline a timeout, or node timeout.
@fangchaooo thanks, can you show a sample about pipeline you defined ?