Closed arisin closed 10 years ago
状況について現在確認できた内容を記述します。
gprofによるプロファイリング結果上位。
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
15.41 0.23 0.23 29491200 0.00 0.00 cv::Mat (anonymous namespace)::cv_mat_cross_with_unorm<cv::Point3_<unsigned char>, unsigned char>(cv::Mat const&, cv::Mat const&)::{lambda(cv::Point3_<unsigned char>, unsigned char)#1}::operator()(cv::Point3_<unsigned char>, unsigned char) const
13.70 0.43 0.20 147455984 0.00 0.00 cv::MatConstIterator::operator++()
8.90 0.56 0.13 29491192 0.00 0.00 cv::Point3_<float>::Point3_(cv::Point3_<float> const&)
5.82 0.64 0.09 96 0.00 0.01 cv::MatIterator_<unsigned char> std::transform<cv::MatConstIterator_<cv::Point3_<float> >, cv::MatIterator_<unsigned char>, (anonymous namespace)::filter_hsv_from_HSV96(cv::Mat const&, float, float, float, float, float, float)::{lambda(cv::Point3_<float> const&)#1}>(cv::MatConstIterator_<cv::Point3_<float> >, cv::MatIterator_<unsigned char>, (anonymous namespace)::filter_hsv_from_HSV96(cv::Mat const&, float, float, float, float, float, float)::{lambda(cv::Point3_<float> const&)#1}, (anonymous namespace)::filter_hsv_from_HSV96(cv::Mat const&, float, float, float, float, float, float)::{lambda(cv::Point3_<float> const&)#1})
5.48 0.72 0.08 29491191 0.00 0.00 (anonymous namespace)::filter_hsv_from_HSV96(cv::Mat const&, float, float, float, float, float, float)::{lambda(cv::Point3_<float> const&)#1}::operator()(cv::Point3_<float> const&) const
5.48 0.80 0.08 192 0.00 0.00 cv::MatConstIterator::operator+=(long)
4.79 0.87 0.07 58982400 0.00 0.00 cv::Point3_<unsigned char>::Point3_(cv::Point3_<unsigned char> const&)
4.11 0.93 0.06 29491200 0.00 0.00 cv::Point3_<unsigned char>::operator=(cv::Point3_<unsigned char> const&)
4.11 0.99 0.06 29491194 0.00 0.00 cv::MatConstIterator_<cv::Point3_<float> >::operator*() const
3.77 1.05 0.06 29491200 0.00 0.00 cv::MatConstIterator_<cv::Point3_<unsigned char> >::operator*() const
2.74 1.09 0.04 29491296 0.00 0.00 bool cv::operator!=<cv::Point3_<unsigned char> >(cv::MatConstIterator_<cv::Point3_<unsigned char> > const&, cv::MatConstIterator_<cv::Point3_<unsigned char> > const&)
2.74 1.13 0.04 29491290 0.00 0.00 bool cv::operator!=<cv::Point3_<float> >(cv::MatConstIterator_<cv::Point3_<float> > const&, cv::MatConstIterator_<cv::Point3_<float> > const&)
2.74 1.17 0.04 29491192 0.00 0.00 cv::MatIterator_<unsigned char>::operator++()
2.05 1.20 0.03 29491200 0.00 0.00 cv::MatConstIterator_<unsigned char>::operator*() const
2.05 1.23 0.03 29491193 0.00 0.00 cv::MatIterator_<unsigned char>::operator*() const
2.05 1.26 0.03 192 0.00 0.00 cv::morphologyDefaultBorderValue()
2.05 1.29 0.03 96 0.00 0.01 cv::MatIterator_<cv::Point3_<unsigned char> > std::transform<cv::MatConstIterator_<cv::Point3_<unsigned char> >, cv::MatConstIterator_<unsigned char>, cv::MatIterator_<cv::Point3_<unsigned char> >, cv::Mat (anonymous namespace)::cv_mat_cross_with_unorm<cv::Point3_<unsigned char>, unsigned char>(cv::Mat const&, cv::Mat const&)::{lambda(cv::Point3_<unsigned char>, unsigned char)#1}>(cv::MatConstIterator_<cv::Point3_<unsigned char> >, cv::MatIterator_<cv::Point3_<unsigned char> >, cv::MatConstIterator_<unsigned char>, cv::Mat (anonymous namespace)::cv_mat_cross_with_unorm<cv::Point3_<unsigned char>, unsigned char>(cv::Mat const&, cv::Mat const&)::{lambda(cv::Point3_<unsigned char>, unsigned char)#1}, cv::Mat (anonymous namespace)::cv_mat_cross_with_unorm<cv::Point3_<unsigned char>, unsigned char>(cv::Mat const&, cv::Mat const&)::{lambda(cv::Point3_<unsigned char>, unsigned char)#1})
1.71 1.31 0.03 29491200 0.00 0.00 cv::MatIterator_<cv::Point3_<unsigned char> >::operator++()
1.37 1.33 0.02 29491200 0.00 0.00 cv::MatConstIterator_<cv::Point3_<unsigned char> >::operator++()
1.37 1.35 0.02 29491200 0.00 0.00 cv::MatConstIterator_<unsigned char>::operator++()
1.37 1.37 0.02 29491200 0.00 0.00 cv::MatIterator_<cv::Point3_<unsigned char> >::operator*() const
1.37 1.39 0.02 29491200 0.00 0.00 std::remove_reference<cv::Point3_<unsigned char>&>::type&& std::move<cv::Point3_<unsigned char>&>(cv::Point3_<unsigned char>&)
1.37 1.41 0.02 192 0.00 0.00 cv::MatIterator_<cv::Point3_<unsigned char> >::MatIterator_(cv::MatIterator_<cv::Point3_<unsigned char> > const&)
0.68 1.42 0.01 29491191 0.00 0.00 cv::MatConstIterator_<cv::Point3_<float> >::operator++()
0.68 1.43 0.01 192 0.00 0.00 cv::MatIterator_<unsigned char>::MatIterator_(cv::MatIterator_<unsigned char> const&)
0.68 1.44 0.01 96 0.00 0.00 std::vector<cv::Vec<float, 3>, std::allocator<cv::Vec<float, 3> > >& boost::range::sort<std::vector<cv::Vec<float, 3>, std::allocator<cv::Vec<float, 3> > >, arisin::etupirka::finger_detector_t::operator()(cv::Mat const&)::{lambda(cv::Vec<float, 3> const&, cv::Vec<float, 3> const&)#1}>(std::vector<cv::Vec<float, 3>, std::allocator<cv::Vec<float, 3> > >, arisin::etupirka::finger_detector_t::operator()(cv::Mat const&)::{lambda(cv::Vec<float, 3> const&, cv::Vec<float, 3> const&)#1})
0.68 1.45 0.01 96 0.00 0.02 arisin::etupirka::finger_detector_t::operator()(cv::Mat const&)
最適化の余地はある。
デスクトップで試した結果、6個のCPUのうち1つのCPUだけに負荷がかかる。他の5個は平均50%前後の負荷。 使用したCPU:AMD Phenom(tm) II X6 1090T
1つのCPUに負荷がかかる現象は、カメラの自動ホワイトバランスと、自動ろしつ補正をOFFにするとよくなる。 (分散される)
参考: うちの開発機にて。(Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz)
0ec646f713595f7b8eeaa63ea693374212afe5e5 における Raspberry Pi 実機での実行結果
./etupirka 2>log
grep 'time_delta' log | awk 'BEGIN{s=999999999} {a+=$7; if(s>$7)s=$7; if(b<$7)b=$7} END{print a/NR, NR, s, b}'
relwithdebinfo: 14752.6 11 14602.2 14865.6
14.752[sec/frame] = 0.067 [FPS]
まだぜんぜん遅すぎる。やはり重い計算処理をPC側に移譲できるモードを検討するか・・・。
3秒台まで軽量化していますので、たぶん動くんじゃないかと思います。Issueが長らく放置されている状態なのでとりあえず閉じます。必要に応じてre-openまたは新たにIssueを発行して下さい。
ビデオの入力、カメラ接続ともにウィンドウが出ない。 よろしくおねがいします。