MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / detectObjectsClip

Method detectObjectsClip

src/CVObjectDetection.cpp:46–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void CVObjectDetection::detectObjectsClip(openshot::Clip &video, size_t _start, size_t _end, bool process_interval)
47{
48
49 start = _start; end = _end;
50
51 video.Open();
52
53 if(error){
54 return;
55 }
56
57 processingController->SetError(false, "");
58
59 // Load names of classes
60 std::ifstream ifs(classesFile.c_str());
61 std::string line;
62 while (std::getline(ifs, line)) classNames.push_back(line);
63
64 // Load the network
65 if(classesFile == "" || modelConfiguration == "" || modelWeights == "")
66 return;
67 net = cv::dnn::readNetFromDarknet(modelConfiguration, modelWeights);
68 setProcessingDevice();
69
70 size_t frame_number;
71 if(!process_interval || end <= 1 || end-start == 0){
72 // Get total number of frames in video
73 start = (int)(video.Start() * video.Reader()->info.fps.ToFloat());
74 end = (int)(video.End() * video.Reader()->info.fps.ToFloat());
75 }
76
77 for (frame_number = start; frame_number <= end; frame_number++)
78 {
79 // Stop the feature tracker process
80 if(processingController->ShouldStop()){
81 return;
82 }
83
84 std::shared_ptr<openshot::Frame> f = video.GetFrame(frame_number);
85
86 // Grab OpenCV Mat image
87 cv::Mat cvimage = f->GetImageCV();
88
89 DetectObjects(cvimage, frame_number);
90
91 // Update progress
92 processingController->SetProgress(uint(100*(frame_number-start)/(end-start)));
93
94 }
95}
96
97void CVObjectDetection::DetectObjects(const cv::Mat &frame, size_t frameId){
98 // Get frame as OpenCV Mat

Callers 2

mainFunction · 0.45

Calls 10

SetErrorMethod · 0.80
ToFloatMethod · 0.80
ShouldStopMethod · 0.80
GetImageCVMethod · 0.80
SetProgressMethod · 0.80
OpenMethod · 0.45
StartMethod · 0.45
ReaderMethod · 0.45
EndMethod · 0.45
GetFrameMethod · 0.45

Tested by

no test coverage detected