MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / demo_segmenter

Function demo_segmenter

yolo_detector/darknet_opt/examples/segmenter.c:177–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175
176
177void demo_segmenter(char *datacfg, char *cfg, char *weights, int cam_index, const char *filename)
178{
179#ifdef OPENCV
180 printf("Classifier Demo\n");
181 network *net = load_network(cfg, weights, 0);
182 set_batch_network(net, 1);
183
184 srand(2222222);
185 CvCapture * cap;
186
187 if(filename){
188 cap = cvCaptureFromFile(filename);
189 }else{
190 cap = cvCaptureFromCAM(cam_index);
191 }
192
193 if(!cap) error("Couldn't connect to webcam.\n");
194 cvNamedWindow("Segmenter", CV_WINDOW_NORMAL);
195 cvResizeWindow("Segmenter", 512, 512);
196 float fps = 0;
197
198 while(1){
199 struct timeval tval_before, tval_after, tval_result;
200 gettimeofday(&tval_before, NULL);
201
202 image in = get_image_from_stream(cap);
203 image in_s = letterbox_image(in, net->w, net->h);
204
205 network_predict(net, in_s.data);
206
207 printf("\033[2J");
208 printf("\033[1;1H");
209 printf("\nFPS:%.0f\n",fps);
210
211 image pred = get_network_image(net);
212 image prmask = mask_to_rgb(pred);
213 show_image(prmask, "Segmenter");
214
215 free_image(in_s);
216 free_image(in);
217 free_image(prmask);
218
219 cvWaitKey(10);
220
221 gettimeofday(&tval_after, NULL);
222 timersub(&tval_after, &tval_before, &tval_result);
223 float curr = 1000000.f/((long int)tval_result.tv_usec);
224 fps = .9*fps + .1*curr;
225 }
226#endif
227}
228
229
230void run_segmenter(int argc, char **argv)

Callers 1

run_segmenterFunction · 0.85

Calls 10

load_networkFunction · 0.85
set_batch_networkFunction · 0.85
errorFunction · 0.85
get_image_from_streamFunction · 0.85
letterbox_imageFunction · 0.85
network_predictFunction · 0.85
get_network_imageFunction · 0.85
mask_to_rgbFunction · 0.85
show_imageFunction · 0.85
free_imageFunction · 0.85

Tested by

no test coverage detected