whoopsidaisies's diary
2019-12-18T19:00:34+09:00
whoopsidaisies
Hatena::Blog
hatenablog://blog/6435988827676239766
Detectron2ã®Model Zooã§ç©ä½æ¤åºãã¤ã³ã¹ã¿ã³ã¹ã»ã°ã¡ã³ãã¼ã·ã§ã³ã姿å¢æ¨å®
hatenablog://entry/26006613486122887
2019-12-18T19:00:34+09:00
2019-12-18T19:00:34+09:00 æ¦è¦ Detectron2ã®Model Zooã«ããè¨ç·´æ¸ã¿ã使ã£ã¦ãç©ä½æ¤åºãã¤ã³ã¹ã¿ã³ã¹ã»ã°ã¡ã³ãã¼ã·ã§ã³ã姿å¢æ¨å®çãè¡ãã å¤ãã®ã¢ãã«ã«å¯¾ãã¦ä¸æ¬ã§å¦çã§ããã³ã¼ããä½ã£ãã便å©ã Detectron2 Facebookã®AIç 究ã°ã«ã¼ãï¼FAIRï¼ãéçºãã¦ããç©ä½æ¤åºã¢ã«ã´ãªãºã ãå®è£
ã®ããã®ã½ããã¦ã§ã¢ã ç°å¢ ubuntu 18.04 GeForce GTX TITAN X ã¤ã³ã¹ãã¼ã« 詳細ã¯çç¥ãã»ã¼å
¬å¼ã®éããã£ããWindowsã§ãããã¨ãããå
¬å¼å¯¾å¿ãã¦ãªããã大å¤ãããªé°å²æ°ã ã¡ã¢ä»£ããã«å¤§éæãªæé ãè¼ãããå
¬å¼ãèªãã§ãã£ãã»ããããã OSãcudaçï¼dâ¦
<h1>æ¦è¦</h1>
<p>Detectron2ã®Model Zooã«ããè¨ç·´æ¸ã¿ã使ã£ã¦ãç©ä½æ¤åºã<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A4%A5%F3%A5%B9%A5%BF%A5%F3%A5%B9">ã¤ã³ã¹ã¿ã³ã¹</a>ã»ã°ã¡ã³ãã¼ã·ã§ã³ã姿å¢æ¨å®çãè¡ãã
å¤ãã®ã¢ãã«ã«å¯¾ãã¦ä¸æ¬ã§å¦çã§ããã³ã¼ããä½ã£ãã便å©ã</p>
<h1><a href="https://github.com/facebookresearch/detectron2">Detectron2</a></h1>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Facebook">Facebook</a>ã®AIç 究ã°ã«ã¼ãï¼FAIRï¼ãéçºãã¦ããç©ä½æ¤åº<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A2%A5%EB%A5%B4%A5%EA%A5%BA%A5%E0">ã¢ã«ã´ãªãºã </a>ãå®è£
ã®ããã®ã½ããã¦ã§ã¢ã</p>
<h1>ç°å¢</h1>
<ul>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/ubuntu">ubuntu</a> 18.04</li>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/GeForce%20GTX">GeForce GTX</a> TITAN X</li>
</ul>
<h1>ã¤ã³ã¹ãã¼ã«</h1>
<p>詳細ã¯çç¥ãã»ã¼å
¬å¼ã®éããã£ãã<a class="keyword" href="http://d.hatena.ne.jp/keyword/Windows">Windows</a>ã§ãããã¨ãããå
¬å¼å¯¾å¿ãã¦ãªããã大å¤ãããªé°å²æ°ã</p>
<p>ã¡ã¢ä»£ããã«å¤§éæãªæé ãè¼ãããå
¬å¼ãèªãã§ãã£ãã»ããããã</p>
<ul>
<li>OSãcudaçï¼dockerã³ã³ããå©ç¨
<ul>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/nvidia">nvidia</a>/cuda:10.1-cudnn7-devel</li>
</ul>
</li>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/Python">Python</a>ç°å¢
<ul>
<li>Anaconda 2019.10ã§python3.7ç°å¢æ§ç¯</li>
</ul>
</li>
<li>pytorch
<ul>
<li><code>conda install pytorch torchvision cudatoolkit=10.1 -c pytorch</code></li>
</ul>
</li>
<li><p>detectron2</p>
<pre><code> git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
python setup.py build develop
</code></pre></li>
</ul>
<h1><a href="https://github.com/facebookresearch/detectron2/blob/master/MODEL_ZOO.md">Detectron2 Model Zoo</a></h1>
<p>å¦ç¿æ¸ã¿ã®ã¢ãã«ãç½®ãã¦ããã
以ä¸ã®ãããªãã®ããããã詳細ã¯<a href="https://github.com/facebookresearch/detectron2/blob/master/MODEL_ZOO.md">ã¦ã§ããµã¤ã</a>åç
§ã</p>
<ul>
<li>ã¿ã¹ã¯
<ul>
<li>COCO Object Detection</li>
<li>COCO Instance Segmentation</li>
<li>COCO Person Keypoint Detection</li>
<li>COCO Panoptic Segmentation</li>
<li>LVIS Instance Segmentation</li>
<li>Cityscapes</li>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/Pascal">Pascal</a> VOC</li>
</ul>
</li>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A2%A5%EB%A5%B4%A5%EA%A5%BA%A5%E0">ã¢ã«ã´ãªãºã </a>
<ul>
<li>Faster R-CNNãRetinaNetãMask R-CNNã<a class="keyword" href="http://d.hatena.ne.jp/keyword/Cascade">Cascade</a> R-CNNç</li>
<li>backbone: <a class="keyword" href="http://d.hatena.ne.jp/keyword/FPN">FPN</a>ãResNetãã¼ã¹ã®ãã®</li>
</ul>
</li>
</ul>
<h1>確èªç¨ã³ã¼ã</h1>
<p>Model Zooã«ããå¦ç¿æ¸ã¿ã¢ãã«ããã¼ãããã¢ã¸ã¥ã¼ã«ã¨ãäºæ¸¬ãã¦å¯è¦åããããã®ã¢ã¸ã¥ã¼ã«ããã£ãã®ã§ããã使ã£ãã</p>
<p>以ä¸ã®ã³ã¼ããå®è¡ããã¨Model Zooã«ããã¢ãã«ã®42åã«ã¤ãã¦äºæ¸¬ãè¡ããã</p>
<pre class="code lang-python" data-lang="python" data-unlink><span class="synPreProc">from</span> detectron2.data.detection_utils <span class="synPreProc">import</span> read_image
<span class="synPreProc">from</span> detectron2.model_zoo.model_zoo <span class="synPreProc">import</span> ModelZooUrls
<span class="synPreProc">from</span> detectron2.config <span class="synPreProc">import</span> get_cfg
<span class="synPreProc">from</span> demo.predictor <span class="synPreProc">import</span> VisualizationDemo
img_path = <span class="synConstant">'input.jpg'</span>
img = read_image(img_path, <span class="synIdentifier">format</span>=<span class="synConstant">"BGR"</span>)
<span class="synStatement">for</span> i, config_path <span class="synStatement">in</span> <span class="synIdentifier">enumerate</span>(ModelZooUrls.CONFIG_PATH_TO_URL_SUFFIX.keys()):
<span class="synComment"># rpnã¨fast_rcnnã¯å¯è¦å対å¿ãã¦ããªãã®ã§é£ã°ã</span>
<span class="synStatement">if</span> <span class="synConstant">'rpn'</span> <span class="synStatement">in</span> config_path <span class="synStatement">or</span> <span class="synConstant">'fast_rcnn'</span> <span class="synStatement">in</span> config_path:
<span class="synStatement">continue</span>
<span class="synComment"># configè¨å®</span>
cfg = get_cfg()
cfg.merge_from_file(f<span class="synConstant">'configs/{config_path}'</span>)
cfg.MODEL.WEIGHTS = ModelZooUrls.get(config_path)
score_thresh = <span class="synConstant">0.5</span>
cfg.MODEL.RETINANET.SCORE_THRESH_TEST = score_thresh
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = score_thresh
cfg.MODEL.PANOPTIC_FPN.COMBINE.INSTANCES_CONFIDENCE_THRESH = score_thresh
cfg.freeze()
<span class="synComment"># æ¤åºï¼å¯è¦å</span>
demo = VisualizationDemo(cfg)
predictions, visualized_output = demo.run_on_image(img)
<span class="synComment"># ãã¡ã¤ã«åºå</span>
dataset_name, algorithm = config_path.split(<span class="synConstant">"/"</span>)
algorithm = algorithm.split(<span class="synConstant">'.'</span>)[<span class="synConstant">0</span>]
visualized_output.save(f<span class="synConstant">'out/{i:02d}-{dataset_name}-{algorithm}.jpg'</span>)
</pre>
<h1>çµæ</h1>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181902.jpg" alt="f:id:whoopsidaisies:20191218181902j:plain" title="f:id:whoopsidaisies:20191218181902j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181904.jpg" alt="f:id:whoopsidaisies:20191218181904j:plain" title="f:id:whoopsidaisies:20191218181904j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181907.jpg" alt="f:id:whoopsidaisies:20191218181907j:plain" title="f:id:whoopsidaisies:20191218181907j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181911.jpg" alt="f:id:whoopsidaisies:20191218181911j:plain" title="f:id:whoopsidaisies:20191218181911j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181914.jpg" alt="f:id:whoopsidaisies:20191218181914j:plain" title="f:id:whoopsidaisies:20191218181914j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181916.jpg" alt="f:id:whoopsidaisies:20191218181916j:plain" title="f:id:whoopsidaisies:20191218181916j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181921.jpg" alt="f:id:whoopsidaisies:20191218181921j:plain" title="f:id:whoopsidaisies:20191218181921j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181926.jpg" alt="f:id:whoopsidaisies:20191218181926j:plain" title="f:id:whoopsidaisies:20191218181926j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181930.jpg" alt="f:id:whoopsidaisies:20191218181930j:plain" title="f:id:whoopsidaisies:20191218181930j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181932.jpg" alt="f:id:whoopsidaisies:20191218181932j:plain" title="f:id:whoopsidaisies:20191218181932j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181935.jpg" alt="f:id:whoopsidaisies:20191218181935j:plain" title="f:id:whoopsidaisies:20191218181935j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181937.jpg" alt="f:id:whoopsidaisies:20191218181937j:plain" title="f:id:whoopsidaisies:20191218181937j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181940.jpg" alt="f:id:whoopsidaisies:20191218181940j:plain" title="f:id:whoopsidaisies:20191218181940j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181943.jpg" alt="f:id:whoopsidaisies:20191218181943j:plain" title="f:id:whoopsidaisies:20191218181943j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181945.jpg" alt="f:id:whoopsidaisies:20191218181945j:plain" title="f:id:whoopsidaisies:20191218181945j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181947.jpg" alt="f:id:whoopsidaisies:20191218181947j:plain" title="f:id:whoopsidaisies:20191218181947j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181950.jpg" alt="f:id:whoopsidaisies:20191218181950j:plain" title="f:id:whoopsidaisies:20191218181950j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181953.jpg" alt="f:id:whoopsidaisies:20191218181953j:plain" title="f:id:whoopsidaisies:20191218181953j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181956.jpg" alt="f:id:whoopsidaisies:20191218181956j:plain" title="f:id:whoopsidaisies:20191218181956j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181959.jpg" alt="f:id:whoopsidaisies:20191218181959j:plain" title="f:id:whoopsidaisies:20191218181959j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182001.jpg" alt="f:id:whoopsidaisies:20191218182001j:plain" title="f:id:whoopsidaisies:20191218182001j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182004.jpg" alt="f:id:whoopsidaisies:20191218182004j:plain" title="f:id:whoopsidaisies:20191218182004j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182007.jpg" alt="f:id:whoopsidaisies:20191218182007j:plain" title="f:id:whoopsidaisies:20191218182007j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182010.jpg" alt="f:id:whoopsidaisies:20191218182010j:plain" title="f:id:whoopsidaisies:20191218182010j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182013.jpg" alt="f:id:whoopsidaisies:20191218182013j:plain" title="f:id:whoopsidaisies:20191218182013j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182016.jpg" alt="f:id:whoopsidaisies:20191218182016j:plain" title="f:id:whoopsidaisies:20191218182016j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182020.jpg" alt="f:id:whoopsidaisies:20191218182020j:plain" title="f:id:whoopsidaisies:20191218182020j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182023.jpg" alt="f:id:whoopsidaisies:20191218182023j:plain" title="f:id:whoopsidaisies:20191218182023j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182026.jpg" alt="f:id:whoopsidaisies:20191218182026j:plain" title="f:id:whoopsidaisies:20191218182026j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182029.jpg" alt="f:id:whoopsidaisies:20191218182029j:plain" title="f:id:whoopsidaisies:20191218182029j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182031.jpg" alt="f:id:whoopsidaisies:20191218182031j:plain" title="f:id:whoopsidaisies:20191218182031j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182035.jpg" alt="f:id:whoopsidaisies:20191218182035j:plain" title="f:id:whoopsidaisies:20191218182035j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182039.jpg" alt="f:id:whoopsidaisies:20191218182039j:plain" title="f:id:whoopsidaisies:20191218182039j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182041.jpg" alt="f:id:whoopsidaisies:20191218182041j:plain" title="f:id:whoopsidaisies:20191218182041j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182044.jpg" alt="f:id:whoopsidaisies:20191218182044j:plain" title="f:id:whoopsidaisies:20191218182044j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182047.jpg" alt="f:id:whoopsidaisies:20191218182047j:plain" title="f:id:whoopsidaisies:20191218182047j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182051.jpg" alt="f:id:whoopsidaisies:20191218182051j:plain" title="f:id:whoopsidaisies:20191218182051j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182055.jpg" alt="f:id:whoopsidaisies:20191218182055j:plain" title="f:id:whoopsidaisies:20191218182055j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182059.jpg" alt="f:id:whoopsidaisies:20191218182059j:plain" title="f:id:whoopsidaisies:20191218182059j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182101.jpg" alt="f:id:whoopsidaisies:20191218182101j:plain" title="f:id:whoopsidaisies:20191218182101j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<div class="images-row mceNonEditable">
<span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182104.jpg" alt="f:id:whoopsidaisies:20191218182104j:plain" title="f:id:whoopsidaisies:20191218182104j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218182107.jpg" alt="f:id:whoopsidaisies:20191218182107j:plain" title="f:id:whoopsidaisies:20191218182107j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181911.jpg" alt="f:id:whoopsidaisies:20191218181911j:plain" title="f:id:whoopsidaisies:20191218181911j:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20191218/20191218181907.jpg" alt="f:id:whoopsidaisies:20191218181907j:plain" title="f:id:whoopsidaisies:20191218181907j:plain" class="hatena-fotolife" itemprop="image"></span>
</div>
<p><div class="images-row mceNonEditable"></p>
whoopsidaisies
denseposeã§U.S.A.
hatenablog://entry/10257846132679628996
2018-12-03T19:37:59+09:00
2018-12-03T19:37:59+09:00 youtu.be å®å
¨ã«åºé
ãããã©ãDensePose使ã£ã¦ã¿ãã®ã§ã¡ã¢ã Facebookçãçºè¡¨ããã2次å
ç»åãã人ä½ã®3Dãµã¼ãã§ã¹ã¢ãã«ãæ¨å®ãã¡ãããããææ³ã 詳細ã¨ã使ãæ¹ã¯ä¸è¨ã®ãã¼ã¸ããããåç
§ã shiropen.com github.com ç°å¢ ubuntu 16.04 nvidia-dockerå°å
¥æ¸ã¿ï¼nvidia-dockerã¤ã³ã¹ãã¼ã«ãã³ã³ããçã¡ã¢ - whoopsidaisies's diaryï¼ å°å
¥ åã人ãdockerhubã§ã¤ã¡ã¼ã¸å
¬éãã¦ããã¦ããã®ã§æ´»ç¨ã åç»ãã¡ã¤ã«ãffmpegã¨ãã§ç»åã«ã°ããã¦ãããã # ubuntu 16.04â¦
<p><iframe width="480" height="270" src="https://www.youtube.com/embed/RONOvSMnlV0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><cite class="hatena-citation"><a href="https://youtu.be/RONOvSMnlV0">youtu.be</a></cite></p>
<p>å®å
¨ã«åºé
ãããã©ã<a href="https://qiita.com/syoyo/items/e9193d18b0970950b9c6:embed">DensePose</a>使ã£ã¦ã¿ãã®ã§ã¡ã¢ã
<a class="keyword" href="http://d.hatena.ne.jp/keyword/Facebook">Facebook</a>çãçºè¡¨ããã2次å
ç»åãã人ä½ã®3D<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%B5%A1%BC%A5%D5%A5%A7%A5%B9">ãµã¼ãã§ã¹</a>ã¢ãã«ãæ¨å®ãã¡ãããããææ³ã</p>
<p>詳細ã¨ã使ãæ¹ã¯ä¸è¨ã®ãã¼ã¸ããããåç
§ã</p>
<p><iframe src="https://hatenablog-parts.com/embed?url=https%3A%2F%2Fshiropen.com%2Fseamless%2Ffacebook-ai-densepose" title="Facebookãã2Dã®ç¾¤è¡åç»ãã人éã®å§¿å¢ãæ¨å®ãã身ä½ã®ãã¯ãã£ãè²¼ã£ã¦ãããCNNãç¨ããã·ã¹ãã ãDensePoseããªã¼ãã³ã½ã¼ã¹çºè¡¨" class="embed-card embed-webcard" scrolling="no" frameborder="0" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;"></iframe><cite class="hatena-citation"><a href="https://shiropen.com/seamless/facebook-ai-densepose">shiropen.com</a></cite>
<iframe src="https://hatenablog-parts.com/embed?url=https%3A%2F%2Fgithub.com%2Ffacebookresearch%2FDensePose" title="facebookresearch/DensePose" class="embed-card embed-webcard" scrolling="no" frameborder="0" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;"></iframe><cite class="hatena-citation"><a href="https://github.com/facebookresearch/DensePose">github.com</a></cite></p>
<h1>ç°å¢</h1>
<ul>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/ubuntu">ubuntu</a> 16.04</li>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/nvidia">nvidia</a>-dockerå°å
¥æ¸ã¿ï¼<a href="http://whoopsidaisies.hatenablog.com/entry/2017/01/22/190618">nvidia-dockerインストール、コンテナ等メモ - whoopsidaisies's diary</a>ï¼</li>
</ul>
<h1>å°å
¥</h1>
<p>åã人ã<a href="https://hub.docker.com/r/garyfeng/densepose/">dockerhubã§ã¤ã¡ã¼ã¸å
¬é</a>ãã¦ããã¦ããã®ã§æ´»ç¨ã
åç»ãã¡ã¤ã«ã<a class="keyword" href="http://d.hatena.ne.jp/keyword/ffmpeg">ffmpeg</a>ã¨ãã§ç»åã«ã°ããã¦ãããã</p>
<pre class="code" data-lang="" data-unlink># ubuntu 16.04ã®ç«¯æ«ã§
nvidia-docker run -it -d --name densepose garyfeng/densepose
docker exec -it densepose bash
# ã³ã³ããå
# å®è¡æã®å¼æ°ã§ãã©ã«ããæå®ããã¨ãã©ã«ãå
ã®ç»åãä¸æ°ã«å¦çãã¦ããã
tools/infer_simple.py \
--cfg configs/DensePose_ResNet101_FPN_s1x-e2e.yaml \
--output-dir /root/data/infer_out/ \
--image-ext png \
--wts https://s3.amazonaws.com/densepose/DensePose_ResNet101_FPN_s1x-e2e.pkl \
/root/data/frame</pre>
<p>以ä¸ãç°¡åã«ã§ãã¦ãããã</p>
whoopsidaisies
OpenCV 3.4.1ã§èæ¯å·®å
hatenablog://entry/17391345971620851816
2018-03-01T13:00:00+09:00
2018-03-01T13:31:22+09:00 OpenCV 3.4.1ã«ããèæ¯å·®åã®ã¢ã«ã´ãªãºã 7種é¡ãæ¯è¼ãGoogle Summer of Code 2017ã§çã¾ããã¢ã«ã´ãªãºã ã®çµæããããã ã£ããC++ãPythonã®ãµã³ãã«ã³ã¼ãããã
<h1>èæ¯å·®å</h1>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20180301/20180301131807.png" alt="f:id:whoopsidaisies:20180301131807p:plain" title="f:id:whoopsidaisies:20180301131807p:plain" class="hatena-fotolife" itemprop="image"></span></p>
<p>ç»åã®åæ¯ã¨èæ¯ãåé¢ããææ³ã2013å¹´ã«<a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/18/092142">OpenCV 2.4.7ã§ã®èæ¯å·®åã®è¨äº</a>ãæ¸ãããã2018å¹´ã«ãªã£ããã¾<a class="keyword" href="http://d.hatena.ne.jp/keyword/OpenCV">OpenCV</a> 3.4.1ã§èæ¯å·®åãè¡ããã¨ããã使ãã<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A2%A5%EB%A5%B4%A5%EA%A5%BA%A5%E0">ã¢ã«ã´ãªãºã </a>ãå¢ãã¦ããã®ã§ã¾ã¨ãã¦ããã</p>
<h1><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A2%A5%EB%A5%B4%A5%EA%A5%BA%A5%E0">ã¢ã«ã´ãªãºã </a></h1>
<h2>MOG, MOG2, GMG</h2>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/OpenCV">OpenCV</a> 2.4.7ã§ã使ããã以ä¸ã®ãã¼ã¸ã«æ¥æ¬èªã§ãããããã説æãããã</p>
<p><a href="http://lang.sist.chukyo-u.ac.jp/classes/OpenCV/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.html">背景差分 — OpenCV-Python Tutorials</a></p>
<h2>KNN</h2>
<p>Kè¿åæ¹ã«åºã¥ãèæ¯å·®åãåæ¯ã®ç»<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C1%C7%BF%F4">ç´ æ°</a>ãå°ãªãå ´åã¯å¹çãè¯ããããã</p>
<p><a href="https://www.sciencedirect.com/science/article/pii/S0167865505003521">Efficient adaptive density estimation per image pixel for the task of background subtraction - ScienceDirect</a></p>
<h2>CNT</h2>
<p>ä½ã¹ããã¯ãªè¨ç®æ©ã§ãã»ãã®<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A2%A5%EB%A5%B4%A5%EA%A5%BA%A5%E0">ã¢ã«ã´ãªãºã </a>ããé«éã«å¦çãã§ãããCNTã¨ããååã¯ãCouNTãã®çç¥ããããRaspberry Pi3ã§ã®<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D9%A5%F3%A5%C1%A5%DE%A1%BC%A5%AF">ãã³ããã¼ã¯</a>ã§ã¯MOG2ã41ç§ã«å¯¾ããCNTã¯18ç§ã</p>
<p><a href="https://sagi-z.github.io/BackgroundSubtractorCNT/">https://sagi-z.github.io/BackgroundSubtractorCNT/</a></p>
<h2>LSBP</h2>
<p>Local <a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a> Binary Patternã注ç®ç»ç´ ã¨ãã®å¨è¾ºç»ç´ ã®å¤§å°é¢ä¿ã符å·åããLBPï¼Local Binary Patternï¼ã¯ãé«éã«è¨ç®å¯è½ãªç»åç¹å¾´éã¨ãã¦ç¥ããã¦ãããå±æçãªãã¤ãºãé£æ¥ç»ç´ ãé¡ä¼¼ãã¦ãããããªå ´åã«ã<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%ED%A5%D0%A5%B9%A5%C8">ããã¹ã</a>ã«ããããã«SVDï¼<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C6%C3%B0%DB%C3%CD%CA%AC%B2%F2">ç¹ç°å¤å解</a>ï¼ã使ã£ãç¹å¾´éã§èæ¯å·®åãè¡ã£ã¦ããããã<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%C1%A4%E3%A4%F3">ã¡ãã</a>ã¨åå¼·ãã¦ãªãã®ã§ãããããããªãã</p>
<p><a href="https://www.cv-foundation.org/openaccess/content_cvpr_2016_workshops/w24/papers/Guo_Background_Subtraction_Using_CVPR_2016_paper.pdf">https://www.cv-foundation.org/openaccess/content_cvpr_2016_workshops/w24/papers/Guo_Background_Subtraction_Using_CVPR_2016_paper.pdf</a></p>
<h2>GSOC</h2>
<p>LSBPç¹å¾´ã使ã£ã¦ãããã¤ãºé¤å»ã¨ãç©´åãã¨ãã£ãå¾å¦çããã¦ããããããGSOC(<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> <a class="keyword" href="http://d.hatena.ne.jp/keyword/Summer%20of%20Code">Summer of Code</a>)2017ä¸ã§éçºãããã¨ãã§å
è«æçã¯ãªããããã®ã§<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%BD%A1%BC%A5%B9%A5%B3%A1%BC%A5%C9">ã½ã¼ã¹ã³ã¼ã</a>ãèªããã</p>
<p><a href="https://github.com/opencv/opencv_contrib/blob/6520dbaa224a661ca8105b1ab0b71451fd715f4c/modules/bgsegm/src/bgfg_gsoc.cpp">opencv_contrib/bgfg_gsoc.cpp at 6520dbaa224a661ca8105b1ab0b71451fd715f4c · opencv/opencv_contrib · GitHub</a></p>
<h1>ã³ã¼ã</h1>
<p>å®è¡ã«ã¯<a href="https://github.com/opencv/opencv_contrib">opencv_contrib</a>ãå¿
è¦ã</p>
<h2><a class="keyword" href="http://d.hatena.ne.jp/keyword/C%2B%2B">C++</a></h2>
<p><code>opencv_contrib</code>ããã¦ã³ãã¼ããã<code>opencv</code>ã®<code>cmake</code>æã«ä¾ãã°ä»¥ä¸ã®ããã«<code>OPENCV_EXTRA_MODULES_PATH</code>ãªãã·ã§ã³ãæå®ãã¦ãã«ãããã</p>
<pre class="code" data-lang="" data-unlink>$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -DBUILD_opencv_legacy=OFF <opencv_source_directory></pre>
<h4><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%BD%A1%BC%A5%B9%A5%B3%A1%BC%A5%C9">ã½ã¼ã¹ã³ã¼ã</a></h4>
<pre class="code lang-cpp" data-lang="cpp" data-unlink><span class="synPreProc">#include </span><span class="synConstant"><opencv2/opencv.hpp></span>
<span class="synPreProc">#include </span><span class="synConstant"><opencv2/core/utility.hpp></span>
<span class="synPreProc">#include </span><span class="synConstant"><opencv2/bgsegm.hpp></span>
<span class="synType">int</span> main()
{
<span class="synComment">// åç»ãã¡ã¤ã«ã®èªã¿è¾¼ã¿</span>
cv::VideoCapture cap = cv::VideoCapture(<span class="synConstant">"video.mp4"</span>);
<span class="synComment">// èæ¯å·®åå¨ã®çæ</span>
cv::Ptr<cv::BackgroundSubtractor> bgfs = cv::bgsegm::createBackgroundSubtractorGSOC();
<span class="synComment">//cv::Ptr<cv::BackgroundSubtractor> bgfs = cv::bgsegm::createBackgroundSubtractorCNT();</span>
<span class="synComment">//cv::Ptr<cv::BackgroundSubtractor> bgfs = cv::bgsegm::createBackgroundSubtractorGMG();</span>
<span class="synComment">//cv::Ptr<cv::BackgroundSubtractor> bgfs = cv::bgsegm::createBackgroundSubtractorLSBP();</span>
<span class="synComment">//cv::Ptr<cv::BackgroundSubtractor> bgfs = cv::bgsegm::createBackgroundSubtractorMOG();</span>
<span class="synComment">//cv::Ptr<cv::BackgroundSubtractor> bgfs = cv::createBackgroundSubtractorMOG2();</span>
<span class="synComment">//cv::Ptr<cv::BackgroundSubtractor> bgfs = cv::createBackgroundSubtractorKNN();</span>
<span class="synStatement">while</span> (cv::waitKey(<span class="synConstant">1</span>) == -<span class="synConstant">1</span>)
{
cv::Mat frame, foreGroundMask, segm;
cap >> frame;
<span class="synStatement">if</span> (frame.empty())
<span class="synStatement">break</span>;
bgfs->apply(frame, foreGroundMask);
frame.convertTo(segm, <span class="synConstant">0</span>, <span class="synConstant">0.5</span>);
cv::add(frame, cv::Scalar(<span class="synConstant">100</span>, <span class="synConstant">100</span>, <span class="synConstant">0</span>), segm, foreGroundMask);
cv::imshow(<span class="synConstant">"output"</span>, segm);
}
<span class="synStatement">return</span> <span class="synConstant">0</span>;
}
</pre>
<h2><a class="keyword" href="http://d.hatena.ne.jp/keyword/Python">Python</a></h2>
<p><code>pip</code>ã§ç®¡çãã¦ããå ´åã以ä¸ã®ããã«<code>opencv-python</code>ãã¢ã³ã¤ã³ã¹ãã¼ã«å¾ã«<code>opencv-contrib-python</code>ãã¤ã³ã¹ãã¼ã«ããã°<code>opencv_contrib</code>ã使ããã</p>
<pre class="code" data-lang="" data-unlink>pip uninstall opencv-python
pip install opencv-contrib-python</pre>
<h4><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%BD%A1%BC%A5%B9%A5%B3%A1%BC%A5%C9">ã½ã¼ã¹ã³ã¼ã</a></h4>
<pre class="code lang-python" data-lang="python" data-unlink><span class="synPreProc">import</span> cv2
cap = cv2.VideoCapture(<span class="synConstant">'video.mp4'</span>)
bgs = cv2.bgsegm.createBackgroundSubtractorLSBP()
<span class="synStatement">while</span>(cap.isOpened()):
ret, frame = cap.read()
mask = bgs.<span class="synIdentifier">apply</span>(frame)
bg = bgs.getBackgroundImage()
cv2.imshow(<span class="synConstant">'mask'</span>, mask)
cv2.imshow(<span class="synConstant">'bg'</span>, bg)
<span class="synStatement">if</span> cv2.waitKey(<span class="synConstant">1</span>) != -<span class="synConstant">1</span>:
<span class="synStatement">break</span>
cap.release()
cv2.destroyAllWindows()
</pre>
<h1>é©ç¨çµæ</h1>
<p>æ¯è¼ã®ããã«å<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A2%A5%EB%A5%B4%A5%EA%A5%BA%A5%E0">ã¢ã«ã´ãªãºã </a>ã並ã¹ã¦ã¿ãããã©ã¡ã¼ã¿èª¿æ´ããã¦ãªãããæ¯è¼ãããããªãæ°ã¯ãããã©ãGSOCã綺éºãLSBPã¯ããã¾ã</p>
<p><iframe width="459" height="344" src="https://www.youtube.com/embed/EILZ4YsI6rU?feature=oembed" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe><cite class="hatena-citation"><a href="https://www.youtube.com/watch?v=EILZ4YsI6rU">www.youtube.com</a></cite></p>
<p>ãã¨ãèæ¯å·®åããã ãã ã£ãããã¶ã以ä¸ã®ãã¼ã¸ã§ç´¹ä»ããã¦ãã<a href="https://github.com/andrewssobral/bgslibrary">BGSLibrary</a>ã使ã£ãã»ããè¯ãããã§ã¯ããã</p>
<p><iframe src="https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.negativemind.com%2F2017%2F07%2F12%2Fbgslibrary%2F" title="OpenCVãã¼ã¹ã®èæ¯å·®åã©ã¤ãã©ãªãBGSLibraryã" class="embed-card embed-webcard" scrolling="no" frameborder="0" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;"></iframe><cite class="hatena-citation"><a href="https://blog.negativemind.com/2017/07/12/bgslibrary/">blog.negativemind.com</a></cite></p>
whoopsidaisies
tensorflowã§MASK R-CNNã«ããSemantic Segmentation
hatenablog://entry/17391345971620252496
2018-02-27T18:44:48+09:00
2018-02-27T18:44:48+09:00 TensorFlow Object Detection APIãç¨ãã¦Mask R-CNNã«ããç»åã®ã»ãã³ãã£ãã¯ã»ã°ã¡ã³ãã¼ã·ã§ã³ãè¡ã£ãã
<h1>ã»ãã³ãã£ãã¯ã»ã°ã¡ã³ãã¼ã·ã§ã³</h1>
<p>ä¸ã®åçã¿ããã«ãå
¥åç»åãç©ä½ãã¨ã«é ååå²ããæè¡ã</p>
<blockquote><p><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20180227/20180227180905.png" alt="f:id:whoopsidaisies:20180227180905p:plain" title="f:id:whoopsidaisies:20180227180905p:plain" class="hatena-fotolife" itemprop="image"></span>
<a href="https://wiki.tum.de/display/lfdv/Image+Semantic+Segmentation">https://wiki.tum.de/display/lfdv/Image+Semantic+Segmentation</a></p></blockquote>
<h1>Mask R-CNN</h1>
<p>æ°ããã»ãã³ãã£ãã¯ã»ã°ã¡ã³ãã¼ã·ã§ã³ãå®ç¾ããææ³ã®ä¸ã§ã2018å¹´2æç¾å¨æåã¨ããã¦ãããã®ã®ä¸ã¤ï¼ãã¶ãï¼ã</p>
<p><iframe width="480" height="270" src="https://www.youtube.com/embed/OOT3UIXZztE?feature=oembed" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe><cite class="hatena-citation"><a href="https://www.youtube.com/watch?v=OOT3UIXZztE">www.youtube.com</a></cite></p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A2%A5%EB%A5%B4%A5%EA%A5%BA%A5%E0">ã¢ã«ã´ãªãºã </a>ã®è©³ç´°ã«ã¤ãã¦ã®èª¬æã¯ä»ã«è²ãã以ä¸ã®ãã¼ã¸ã¨ããåèã«ããã</p>
<ul>
<li><a href="https://arxiv.org/pdf/1703.06870.pdf">https://arxiv.org/pdf/1703.06870.pdf</a></li>
<li><a href="http://kaiminghe.com/iccv17tutorial/maskrcnn_iccv2017_tutorial_kaiminghe.pdf">http://kaiminghe.com/iccv17tutorial/maskrcnn_iccv2017_tutorial_kaiminghe.pdf</a></li>
<li><a href="http://deeplearning.csail.mit.edu/instance_ross.pdf">http://deeplearning.csail.mit.edu/instance_ross.pdf</a></li>
</ul>
<h1>TensorFlowã®ã¤ã³ã¹ãã¼ã«</h1>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%C0%E8%C0%B8">Googleå
ç</a>ãå
¬éãã¦ãã<a class="keyword" href="http://d.hatena.ne.jp/keyword/%B5%A1%B3%A3%B3%D8%BD%AC">æ©æ¢°å¦ç¿</a>ç¨<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%AA%A1%BC%A5%D7%A5%F3%A5%BD%A1%BC%A5%B9">ãªã¼ãã³ã½ã¼ã¹</a>ã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«æ¹æ³ã¯å··ã«ããµãã¦ããã®ã§é©å½ã«ã°ã°ã£ã¦ã¤ã³ã¹ãã¼ã«ããã</p>
<h1>Tensorflow Object Detection <a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>ã®ã¤ã³ã¹ãã¼ã«</h1>
<p>以ä¸ã®<a class="keyword" href="http://d.hatena.ne.jp/keyword/GitHub">GitHub</a>ã®ã¬ãã¸ããªã§æ§ã
ãªTensorfFlowã®ã¢ãã«ãå
¬éããã¦ãããå
¬å¼ãµãã¼ãã§ã¯ãªããç©ä½æ¤åºã¨ã»ãã³ãã£ãã¯ã»ã°ã¡ã³ãã¼ã·ã§ã³ã®ã¢ãã«ãæ°å¤ãå
¬éããã¦ããã®ã§ãä»åã¯ããã使ãã</p>
<p><iframe src="https://hatenablog-parts.com/embed?url=https%3A%2F%2Fgithub.com%2Ftensorflow%2Fmodels" title="tensorflow/models" class="embed-card embed-webcard" scrolling="no" frameborder="0" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;"></iframe><cite class="hatena-citation"><a href="https://github.com/tensorflow/models">github.com</a></cite></p>
<p>ã¤ã³ã¹ãã¼ã«ã¯å
¬å¼ã®æé éãã ã以ä¸ã«é©å½ã«ã¡ã¢ã
<a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md">models/installation.md at master · tensorflow/models · GitHub</a></p>
<ul>
<li>ä¾åããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«</li>
</ul>
<pre class="code" data-lang="" data-unlink>apt install protobuf-compiler
pip install pillow lxml jupyter matplotlib</pre>
<ul>
<li>Protobufãã¡ã¤ã«ã<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%B3%A5%F3%A5%D1%A5%A4%A5%EB">ã³ã³ãã¤ã«</a></li>
</ul>
<pre class="code" data-lang="" data-unlink>cd [PATH to models]/research
protoc object_detection/protos/*.proto --python_out=.</pre>
<ul>
<li>PYTHONPATHã®è¿½å </li>
</ul>
<pre class="code" data-lang="" data-unlink>cd [PATH to models]/research
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim</pre>
<h1>ã¢ãã«ãã¡ã¤ã«ã®ãã¦ã³ãã¼ã</h1>
<p><a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md">Tensorflow detection model zoo</a>ããç©ä½æ¤åºãã»ãã³ãã£ãã¯ã»ã°ã¡ã³ãã¼ã·ã§ã³ã®ãã¬ã¼ãã³ã°æ¸ã¿ã¢ãã«ããã¦ã³ãã¼ãåºæ¥ããã¨ããããä¸çªmAPã®é«ã<a href="http://download.tensorflow.org/models/object_detection/mask_rcnn_inception_resnet_v2_atrous_coco_2018_01_28.tar.gz">mask_rcnn_inception_resnet_v2_atrous_coco</a>ã¨ããã¢ãã«ã使ãã</p>
<pre class="code" data-lang="" data-unlink>wget http://download.tensorflow.org/models/object_detection/mask_rcnn_inception_resnet_v2_atrous_coco_2018_01_28.tar.gz
tar -zxvf mask_rcnn_inception_resnet_v2_atrous_coco_2018_01_28.tar.gz</pre>
<h1>ã»ãã³ãã£ãã¯ã»ã°ã¡ã³ãã¼ã·ã§ã³ã®<a class="keyword" href="http://d.hatena.ne.jp/keyword/python">python</a>ã³ã¼ã</h1>
<pre class="code lang-python" data-lang="python" data-unlink><span class="synPreProc">import</span> tensorflow <span class="synStatement">as</span> tf
<span class="synPreProc">import</span> numpy <span class="synStatement">as</span> np
<span class="synPreProc">from</span> PIL <span class="synPreProc">import</span> Image
<span class="synPreProc">from</span> object_detection.utils <span class="synPreProc">import</span> ops <span class="synStatement">as</span> utils_ops
<span class="synPreProc">import</span> sys
sys.path.append(<span class="synConstant">'[modelsã®ãã¹]/research/object_detection'</span>)
<span class="synPreProc">from</span> utils <span class="synPreProc">import</span> label_map_util
<span class="synPreProc">from</span> utils <span class="synPreProc">import</span> visualization_utils <span class="synStatement">as</span> vis_util
<span class="synComment"># å¦ç¿æ¸ã¢ãã«ã®èªã¿è¾¼ã¿</span>
PATH_TO_CKPT = <span class="synConstant">'mask_rcnn_inception_resnet_v2_atrous_coco_2018_01_28/frozen_inference_graph.pb'</span>
detection_graph = tf.Graph()
<span class="synStatement">with</span> detection_graph.as_default():
od_graph_def = tf.GraphDef()
<span class="synStatement">with</span> tf.gfile.GFile(PATH_TO_CKPT, <span class="synConstant">'rb'</span>) <span class="synStatement">as</span> fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name=<span class="synConstant">''</span>)
<span class="synComment"># ã©ãã«ã®èªã¿è¾¼ã¿</span>
PATH_TO_LABELS = <span class="synConstant">'[modelsã¸ã®ãã¹]/research/object_detection/data/mscoco_label_map.pbtxt'</span>
NUM_CLASSES = <span class="synConstant">90</span>
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=<span class="synIdentifier">True</span>)
category_index = label_map_util.create_category_index(categories)
<span class="synComment"># ç»åã®èªã¿è¾¼ã¿ã¨numpyé
åã¸ã®å¤æ</span>
<span class="synStatement">def</span> <span class="synIdentifier">load_image_into_numpy_array</span>(image):
(im_width, im_height) = image.size
<span class="synStatement">return</span> np.array(image.getdata()).reshape(
(im_height, im_width, <span class="synConstant">3</span>)).astype(np.uint8)
filename = <span class="synConstant">'[ç»åãã¡ã¤ã«ã®ãã¹]'</span>
image = Image.<span class="synIdentifier">open</span>(filename)
image_np = load_image_into_numpy_array(image)
<span class="synComment"># ã»ãã³ãã£ãã¯ã»ã°ã¡ã³ãã¼ã·ã§ã³ã®å¦ç</span>
<span class="synStatement">with</span> detection_graph.as_default():
<span class="synStatement">with</span> tf.Session() <span class="synStatement">as</span> sess:
<span class="synComment"># å
¥åºåç¨ãã³ã½ã«ã®ãã³ãã«ãåå¾</span>
image_tensor = tf.get_default_graph().get_tensor_by_name(<span class="synConstant">'image_tensor:0'</span>)
tensor_dict = {}
tensor_dict[<span class="synConstant">'num_detections'</span>] = tf.get_default_graph().get_tensor_by_name(<span class="synConstant">'num_detections:0'</span>)
tensor_dict[<span class="synConstant">'detection_boxes'</span>] = tf.get_default_graph().get_tensor_by_name(<span class="synConstant">'detection_boxes:0'</span>)
tensor_dict[<span class="synConstant">'detection_scores'</span>] = tf.get_default_graph().get_tensor_by_name(<span class="synConstant">'detection_scores:0'</span>)
tensor_dict[<span class="synConstant">'detection_classes'</span>] = tf.get_default_graph().get_tensor_by_name(<span class="synConstant">'detection_classes:0'</span>)
tensor_dict[<span class="synConstant">'detection_masks'</span>] = tf.get_default_graph().get_tensor_by_name(<span class="synConstant">'detection_masks:0'</span>)
<span class="synComment"># ãããå
ã®æåã®ç»åã®çµæãåãåºã</span>
detection_boxes = tf.squeeze(tensor_dict[<span class="synConstant">'detection_boxes'</span>], [<span class="synConstant">0</span>])
detection_masks = tf.squeeze(tensor_dict[<span class="synConstant">'detection_masks'</span>], [<span class="synConstant">0</span>])
<span class="synComment"># åæ¤åºããã¯ã¹ã®ãã¹ã¯ãç»åå
¨ä½ä¸ã®ãã¹ã¯ã¸å¤æ</span>
real_num_detection = tf.cast(tensor_dict[<span class="synConstant">'num_detections'</span>][<span class="synConstant">0</span>], tf.int32)
detection_boxes = tf.<span class="synIdentifier">slice</span>(detection_boxes, [<span class="synConstant">0</span>, <span class="synConstant">0</span>], [real_num_detection, -<span class="synConstant">1</span>])
detection_masks = tf.<span class="synIdentifier">slice</span>(detection_masks, [<span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>], [real_num_detection, -<span class="synConstant">1</span>, -<span class="synConstant">1</span>])
detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(
detection_masks, detection_boxes, image_np.shape[<span class="synConstant">0</span>], image_np.shape[<span class="synConstant">1</span>])
detection_masks_reframed = tf.cast(
tf.greater(detection_masks_reframed, <span class="synConstant">0.5</span>), tf.uint8)
<span class="synComment"># ãããåã®æ¬¡å
ã追å </span>
tensor_dict[<span class="synConstant">'detection_masks'</span>] = tf.expand_dims(
detection_masks_reframed, <span class="synConstant">0</span>)
<span class="synComment"># å®è¡</span>
output_dict = sess.run(tensor_dict,
feed_dict={image_tensor: np.expand_dims(image_np, <span class="synConstant">0</span>)})
<span class="synComment"># ãããåã®æ¬¡å
ã®åé¤ã¨åå¤æ</span>
output_dict[<span class="synConstant">'num_detections'</span>] = <span class="synIdentifier">int</span>(output_dict[<span class="synConstant">'num_detections'</span>][<span class="synConstant">0</span>])
output_dict[<span class="synConstant">'detection_classes'</span>] = output_dict[
<span class="synConstant">'detection_classes'</span>][<span class="synConstant">0</span>].astype(np.uint8)
output_dict[<span class="synConstant">'detection_boxes'</span>] = output_dict[<span class="synConstant">'detection_boxes'</span>][<span class="synConstant">0</span>]
output_dict[<span class="synConstant">'detection_scores'</span>] = output_dict[<span class="synConstant">'detection_scores'</span>][<span class="synConstant">0</span>]
output_dict[<span class="synConstant">'detection_masks'</span>] = output_dict[<span class="synConstant">'detection_masks'</span>][<span class="synConstant">0</span>]
<span class="synComment"># ç»åã«ãã¹ã¯ã¨ãã¦ã³ãã£ã³ã°ããã¯ã¹ãæ¸ãè¾¼ãã§åºå</span>
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
output_dict[<span class="synConstant">'detection_boxes'</span>],
output_dict[<span class="synConstant">'detection_classes'</span>],
output_dict[<span class="synConstant">'detection_scores'</span>],
category_index,
instance_masks=output_dict.get(<span class="synConstant">'detection_masks'</span>),
use_normalized_coordinates=<span class="synIdentifier">True</span>,
line_thickness=<span class="synConstant">8</span>)
Image.fromarray(image_np).save(<span class="synConstant">'out.png'</span>)
</pre>
<h1>çµæ</h1>
<p>æ¾ã£ã¦ããããªã¼åçã«é©ç¨ããçµæã以ä¸ãæã ãåã£ã¦ã¦ã人éã£ã¦å¤æãã¦ãããã®ãã</p>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20180227/20180227183425.png" alt="f:id:whoopsidaisies:20180227183425p:plain" title="f:id:whoopsidaisies:20180227183425p:plain" class="hatena-fotolife" itemprop="image"></span></p>
whoopsidaisies
nvidia-dockerã¤ã³ã¹ãã¼ã«ãã³ã³ããçã¡ã¢
hatenablog://entry/10328749687208981069
2017-01-22T19:06:18+09:00
2017-01-22T19:06:18+09:00 åºæ¬çã«å
¬å¼ãµã¤ãã®èª¬æã¨ãã®éãã«ããã ããªãã ãã©èªåç¨ã«ã¡ã¢ã ãã¹ãOSï¼ubuntu 16.04LTS dockerã®ã¤ã³ã¹ãã¼ã« åèï¼ Get Docker for Ubuntu - Docker # httpséä¿¡ã§å
¬ééµãã¦ã³ãã¼ããããã apt-get update apt-get install curl ca-certificates # dockerã¬ãã¸ããªã®å
¬ééµã®ç»é² curl -fsSL https://yum.dockerproject.org/gpg | apt-key add - # add-apt-repositoryã³ãã³ãã®ã¤ã³ã¹ãã¼ã« apt-â¦
<p>åºæ¬çã«å
¬å¼ãµã¤ãã®èª¬æã¨ãã®éãã«ããã ããªãã ãã©èªåç¨ã«ã¡ã¢ã</p>
<p>ãã¹ãOSï¼<a class="keyword" href="http://d.hatena.ne.jp/keyword/ubuntu">ubuntu</a> 16.04LTS</p>
<h1>dockerã®ã¤ã³ã¹ãã¼ã«</h1>
<p>åèï¼
<a href="https://docs.docker.com/engine/installation/linux/ubuntu/"><img src="https://cdn-ak.favicon.st-hatena.com/?url=https%3A%2F%2Fdocs.docker.com%2Fengine%2Finstallation%2Flinux%2Fubuntu%2F" alt="" class="http-favicon" /></a><a href="https://docs.docker.com/engine/installation/linux/ubuntu/">Get Docker for Ubuntu - Docker</a></p>
<pre class="code" data-lang="" data-unlink># httpséä¿¡ã§å
¬ééµãã¦ã³ãã¼ããããã
apt-get update
apt-get install curl ca-certificates
# dockerã¬ãã¸ããªã®å
¬ééµã®ç»é²
curl -fsSL https://yum.dockerproject.org/gpg | apt-key add -
# add-apt-repositoryã³ãã³ãã®ã¤ã³ã¹ãã¼ã«
apt-get install software-properties-common
# dockerã¬ãã¸ããªè¿½å
add-apt-repository "deb https://apt.dockerproject.org/repo/ ubuntu-$(lsb_release -cs) main"
# aptã§httpséä¿¡ãããã
apt-get install apt-transport-https
# dockerã®ã¤ã³ã¹ãã¼ã«
apt-get update
apt-get install docker-engine</pre>
<h1><a class="keyword" href="http://d.hatena.ne.jp/keyword/NVIDIA">NVIDIA</a>ãã©ã¤ãã®ã¤ã³ã¹ãã¼ã«</h1>
<p>ãããä¸çªããã£ã¦å¤§å¤ãªå ´åãå¤ãæ°ãããããããã§ã¯çç¥ãã©ãã«ããã¾ããã¨ã¤ã³ã¹ãã¼ã«ããã</p>
<h1><a class="keyword" href="http://d.hatena.ne.jp/keyword/NVIDIA">NVIDIA</a> Dockerã®ã¤ã³ã¹ãã¼ã«</h1>
<pre class="code" data-lang="" data-unlink># debããã±ã¼ã¸ã®ãã¦ã³ãã¼ãï¼2017/1/22ç¾å¨ã§ææ°ã®ãã®ï¼
curl -LO https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.0/nvidia-docker_1.0.0-1_amd64.deb
# ã¤ã³ã¹ãã¼ã«
dpkg -i nvidia-docker_1.0.0-1_amd64.deb
rm nvidia-docker_1.0.0-1_amd64.deb
# åä½ç¢ºèªï¼GPUæ
å ±ã表示ãããã¨è¯ãï¼
nvidia-docker run --rm nvidia/cuda nvidia-smi</pre>
<p>ãã¼ã¸ã§ã³ã«ã¤ãã¦ã¯ä¸è¨ãã¼ã¸ã§ãã§ãã¯ãã¦é©å®ãã¦ã³ãã¼ããããã®ã確èªããã</p>
<p><a href="https://github.com/NVIDIA/nvidia-docker/releases"><img src="https://cdn-ak.favicon.st-hatena.com/?url=https%3A%2F%2Fgithub.com%2FNVIDIA%2Fnvidia-docker%2Freleases" alt="" class="http-favicon" /></a><a href="https://github.com/NVIDIA/nvidia-docker/releases">Releases · NVIDIA/nvidia-docker · GitHub</a></p>
<h1><a class="keyword" href="http://d.hatena.ne.jp/keyword/NVIDIA">NVIDIA</a> Dockerã³ã³ããã¡ã¢</h1>
<p>便å©ãªãã®ãããã°éæ追è¨äºå®ã</p>
<ul>
<li><a href="https://hub.docker.com/u/nvidia/">https://hub.docker.com/u/nvidia/</a><br/>
<a class="keyword" href="http://d.hatena.ne.jp/keyword/nvidia">nvidia</a>å
¬å¼ã³ã³ãããCUDAãCuDNNã®ãã¼ã¸ã§ã³ãOSã®ç¨®é¡ãé¸ã¹ãã</li>
<li><a href="https://hub.docker.com/u/kaixhin/">https://hub.docker.com/u/kaixhin/</a><br/>
ã¤ã®ãªã¹ã®ç 究è
ä½æã®ã³ã³ãããè²ã
ãã£ã¦ä¾¿å©ã</li>
</ul>
whoopsidaisies
C#ã§3次å
ã°ã©ãã表示ãã ILNumerics
hatenablog://entry/8454420450075953018
2014-12-02T18:32:47+09:00
2014-12-02T18:32:47+09:00 ILNumericsã¯.NETã§ä½¿ç¨å¯è½ãªæ°å¤è¨ç®çã®ã©ã¤ãã©ãªã§ããï¼ã°ã©ã表示æ©è½ãåãã£ã¦ããã®ã§ï¼ããã使ã£ã¦C#ã®Windowsãã©ã¼ã ä¸ã«3次å
ã°ã©ãã表示ããï¼ ILNumericsã®ã¤ã³ã¹ãã¼ã« ç¾å¨ææ°ãã¼ã¸ã§ã³ï¼4.xç³»ï¼ã®ILNumericsã¯14æ¥éã®ãã©ã¤ã¢ã«ç以å¤ã¯æåã ãï¼Community Editionã¨ããç¡åçãæä¾ããã¦ãã3.xç³»ã®ãã¼ã¸ã§ã³ãNuGetã§ã¤ã³ã¹ãã¼ã«å¯è½ãªã®ã§ããã使ãï¼ã¾ãï¼Visual Studioã§Windowsãã©ã¼ã ã¢ããªã±ã¼ã·ã§ã³ãä½æããï¼ããã¦ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³â¦
<p><a href="http://ilnumerics.net/">ILNumerics</a>ã¯.NETã§ä½¿ç¨å¯è½ãªæ°å¤è¨ç®çã®ã©ã¤ãã©ãªã§ããï¼ã°ã©ã表示æ©è½ãåãã£ã¦ããã®ã§ï¼ããã使ã£ã¦C#ã®Windowsãã©ã¼ã ä¸ã«3次å
ã°ã©ãã表示ããï¼</p>
<div class="section">
<h3>ILNumericsã®ã¤ã³ã¹ãã¼ã«</h3>
<p>ç¾å¨ææ°ãã¼ã¸ã§ã³ï¼4.xç³»ï¼ã®ILNumericsã¯<a href="http://ilnumerics.net/shop.html">14日間のトライアル版以外は有償</a>ã ãï¼<a href="http://ilnumerics.net/closed-source-version-available.html">Community Editionという無償版が提供されていた3.x系のバージョン</a>ã<a href="https://www.nuget.org/packages/ILNumerics/">NuGetでインストール可能</a>ãªã®ã§ããã使ãï¼</p><p>ã¾ãï¼Visual Studioã§Windowsãã©ã¼ã ã¢ããªã±ã¼ã·ã§ã³ãä½æããï¼</p><p>ããã¦ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããILNumericsããæ¤ç´¢ã»ã¤ã³ã¹ãã¼ã«ããï¼</p>
</div>
<div class="section">
<h3>ã°ã©ã表示ç¨ã³ã³ããã¼ã«ã®é
ç½®</h3>
<p>ãã©ã¼ã ãã¶ã¤ããéããã¼ã«ããã¯ã¹ã®é©å½ãªã¨ããã§å³ã¯ãªãã¯ãã¦ãã¢ã¤ãã ã®é¸æ(I)...ããé¸æããï¼</p><p>ã.NET Framework ã³ã³ãã¼ãã³ããã¿ãã®ãåç
§(B)...ããã¿ã³ãæ¼ãã¦ï¼ã(ã½ãªã¥ã¼ã·ã§ã³ã®ãã¹)\packages\ILNumerics.3.3.3.0\lib\ILNumerics.dllããé¸æãããOKï¼</p><p>ããã¨ãã¼ã«ããã¯ã¹ILââã¨ããã³ã³ããã¼ã«ã追å ãããï¼ãã®ä¸ã®ï¼ILPanelã³ã³ããã¼ã«ããã©ã¼ã ä¸ã«é
ç½®ããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141202/20141202163400.png" alt="f:id:whoopsidaisies:20141202163400p:plain" title="f:id:whoopsidaisies:20141202163400p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>使ã£ã¦ã¿ã</h3>
<div class="section">
<h4>æ²é¢</h4>
<p>ä¾ã¨ãã¦ï¼ä»¥ä¸ã®2å¤æ°é¢æ°ã表示ããã¦ã¿ãï¼<br />
<img src="http://chart.apis.google.com/chart?cht=tx&chl=z%3D%5Cfrac%7B%5Csin%28%5Csqrt%7Bx%5E2%2By%5E2%7D%29%7D%7B%5Csqrt%7Bx%5E2%2By%5E2%7D%7D" alt="z=\frac{\sin(\sqrt{x^2+y^2})}{\sqrt{x^2+y^2}}"/></p><p>ã¾ãï¼ã³ã¼ãã®é©å½ãªå ´æã«ä»¥ä¸ã®usingãæ¸ãã¦ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synStatement">using</span> ILNumerics.Drawing;
<span class="synStatement">using</span> ILNumerics.Drawing.Plotting;
</pre><p>ããã¦ï¼ãã©ã¼ã ãã¼ãã¤ãã³ãã¨ãã®é©å½ãªã¤ãã³ãã«ä»¥ä¸ã®ã³ã¼ããæ¸ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// ã°ã©ããæ ¼ç´ãããªãã¸ã§ã¯ãã®çæ</span>
var scene = <span class="synStatement">new</span> ILScene
{
<span class="synComment">// 3次å
ã¢ã¼ãã§ããããé åãçæ</span>
<span class="synStatement">new</span> ILPlotCube(twoDMode: <span class="synConstant">false</span>)
{
<span class="synComment">// æ²é¢ã®çæ</span>
<span class="synStatement">new</span> ILSurface(
(x,y) => (<span class="synType">float</span>)(
Math.Sin(Math.Sqrt(x*x + y*y))/Math.Sqrt(x*x + y*y)))
}
};
<span class="synComment">// æç»ç¨ã³ã³ããã¼ã«ã«çæããã°ã©ããã»ãã</span>
ilPanel1.Scene = scene;
</pre><p>å®è¡ããã¨ä»¥ä¸ã®ããã«3次å
ã°ã©ãã表示ãããï¼ãã¦ã¹ãã©ãã°ã¨ããã¤ã¼ã«ã¨ãã§è¦ç¹ãæ¡å¤§çãå¤ããããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141202/20141202172655.png" alt="f:id:whoopsidaisies:20141202172655p:plain" title="f:id:whoopsidaisies:20141202172655p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h4>çé«ç·</h4>
<p>ãµã³ãã«ç¨ã®å°å½¢ãã¼ã¿ãç¨æããã¦ãã¦ï¼ä»¥ä¸ã®ããã«ä½¿ããã¨ãåºæ¥ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>var scene = <span class="synStatement">new</span> ILScene
{
<span class="synStatement">new</span> ILPlotCube(twoDMode: <span class="synConstant">false</span>){
<span class="synStatement">new</span> ILSurface(ILNumerics.ILMath.tosingle(ILNumerics.ILSpecialData.terrain))
}
};
ilPanel1.Scene = scene;
</pre><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141202/20141202180125.png" alt="f:id:whoopsidaisies:20141202180125p:plain" title="f:id:whoopsidaisies:20141202180125p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>ããã¾ã§ã¯æ²é¢è¡¨ç¤ºã®ããILSurfaceã¯ã©ã¹ã使ã£ã¦ãããï¼ILContourPlotã¯ã©ã¹ã使ãã°ä»¥ä¸ã®ããã«çé«ç·è¡¨ç¤ºãåºæ¥ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>var scene = <span class="synStatement">new</span> ILScene
{
<span class="synStatement">new</span> ILPlotCube{
<span class="synStatement">new</span> ILContourPlot(ILNumerics.ILMath.tosingle(ILNumerics.ILSpecialData.terrain))
}
};
ilPanel1.Scene = scene;
</pre><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141202/20141202180132.png" alt="f:id:whoopsidaisies:20141202180132p:plain" title="f:id:whoopsidaisies:20141202180132p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h4>æ£å¸å³</h4>
<p>ILPointsã¯ã©ã¹ã§æ£å¸å³ã表示ããããã¨ãåºæ¥ãï¼ä»¥ä¸ã¯ã©ã³ãã ã«ç¹ãæã£ã¦å¯¾æ°è»¸ã«ãã¦è¡¨ç¤ºããä¾ï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>ILNumerics.ILArray<<span class="synType">float</span>> p = ILNumerics.ILMath.tosingle(ILNumerics.ILMath.rand(<span class="synConstant">3</span>, <span class="synConstant">10000</span>));
var scene = <span class="synStatement">new</span> ILScene{
<span class="synStatement">new</span> ILPlotCube(twoDMode:<span class="synConstant">false</span>){
<span class="synStatement">new</span> ILPoints
{
Positions = p,
Color = <span class="synConstant">null</span>,
Colors = p,
Size = <span class="synConstant">1</span>,
}
}
};
var scaleModes = scene.First<ILPlotCube>().ScaleModes;
scaleModes.XAxisScale = AxisScale.Logarithmic;
scaleModes.YAxisScale = AxisScale.Logarithmic;
scaleModes.ZAxisScale = AxisScale.Logarithmic;
ilPanel1.Scene = scene;
</pre><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141202/20141202182150.png" alt="f:id:whoopsidaisies:20141202182150p:plain" title="f:id:whoopsidaisies:20141202182150p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
</div>
whoopsidaisies
Python+OpenCVã§ç¹å¾´éè¨è¿°ã»ã¢ã«ã´ãªãºã ã¾ã¨ã
hatenablog://entry/8454420450075890810
2014-12-01T23:50:13+09:00
2014-12-01T23:50:13+09:00 Python+OpenCVã§ç»åã®ç¹å¾´ç¹ã®ç¹å¾´éãè¨è¿°ããï¼OpenCV2.4.9ããã³OpenCV3.0 alphaã«ã¤ãã¦ä½¿ç¨ã§ããã¢ã«ã´ãªãºã ãã¾ã¨ããï¼Python+OpenCVã§ç¹å¾´ç¹æ½åºã»ä½¿ããã¢ã«ã´ãªãºã ã¾ã¨ã OpenCV2.4.9ã¨3.0 alpha - whoopsidaisies's diary ã®ç¶ãï¼ ç°å¢ Windowsã§OpenCVå
¬å¼ãµã¤ãã®ãã¦ã³ãã¼ããã¼ã¸ãã2.4.9ããã³3.0 alphaã®ãã«ãæ¸ã¿ãã¤ããªããã¦ã³ãã¼ããã¦ãã¦è§£åãããã®ã使ãï¼ ç¹å¾´éè¨è¿°å¨ã®ä½¿ãæ¹ ç¹å¾´ç¹æ½åºã®ã¨ãã®FeatureDetectorã¨åãããã«ï¼ç¹å¾´éè¨è¿°ã«ã¤ãã¦ãâ¦
<p>Python+OpenCVã§ç»åã®ç¹å¾´ç¹ã®ç¹å¾´éãè¨è¿°ããï¼OpenCV2.4.9ããã³OpenCV3.0 alphaã«ã¤ãã¦ä½¿ç¨ã§ããã¢ã«ã´ãªãºã ãã¾ã¨ããï¼</p><p><a href="http://whoopsidaisies.hatenablog.com/entry/2014/12/01/031213"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2014%2F12%2F01%2F031213" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2014/12/01/031213">Python+OpenCVで特徴点抽出・使えるアルゴリズムまとめ OpenCV2.4.9と3.0 alpha - whoopsidaisies's diary</a><br />
ã®ç¶ãï¼</p>
<div class="section">
<h3>ç°å¢</h3>
<p>Windowsã§OpenCVå
¬å¼ãµã¤ãã®<a href="http://opencv.org/downloads.html">ダウンロードページ</a>ãã<a href="https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.9/opencv-2.4.9.exe/download">2.4.9</a>ããã³<a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0-alpha/">3.0 alpha</a>ã®ãã«ãæ¸ã¿ãã¤ããªããã¦ã³ãã¼ããã¦ãã¦è§£åãããã®ã使ãï¼</p>
</div>
<div class="section">
<h3>ç¹å¾´éè¨è¿°å¨ã®ä½¿ãæ¹</h3>
<p>ç¹å¾´ç¹æ½åºã®ã¨ãã®FeatureDetectorã¨åãããã«ï¼ç¹å¾´éè¨è¿°ã«ã¤ãã¦ãDescriptorExtractorã¨ããå
±éã¤ã³ã¿ã¼ãã§ã¼ã¹ãç¨æããã¦ããï¼</p><p>使ãæ¹ã¯ä»¥ä¸ã®éãï¼</p>
<pre class="code lang-python" data-lang="python" data-unlink><span class="synComment"># å¼æ°ã§ã©ã®ç¹å¾´éè¨è¿°åã使ããæå® </span>
extractor = cv2.DescriptorExtractor_create(extractor_name)
<span class="synComment"># å¼æ°ã¨ãã¦ç»åã¨ç¹å¾´ç¹ã渡ã</span>
<span class="synComment"># æ»ãå¤ã¯ç¹å¾´ç¹ã¨ç¹å¾´é</span>
keypoints, descriptors = extractor.compute(img, keypoints)
</pre><p>DescriptorExtractor_createã¡ã½ããã§æå®åºæ¥ãç¹å¾´éè¨è¿°åã以ä¸ã«ã¾ã¨ããï¼</p>
<table>
<tr>
<td>OpenCVãã¼ã¸ã§ã³</td>
<th> å®æ°ãã¯ãã«</th>
<th> ãã¤ããªã³ã¼ã</th>
</tr>
<tr>
<td>2.4.9</td>
<td>SIFT, SURF</td>
<td>BRIEF, BRISK, <del>ORB</del>, FREAK</td>
</tr>
<tr>
<td>3.0 alpha</td>
<td>KAZE</td>
<td>AKAZE, BRISK, ORB</td>
</tr>
</table><p>ï¼2.4.9ã§ORBããªããã©ã³ã¿ã¤ã ã¨ã©ã¼ãåºãã®ã§è¿½ã
調æ»äºå®ï¼</p>
</div>
<div class="section">
<h3>ç¹å¾´éã®ä¸èº«</h3>
<p>descriptorsã®ä¸èº«ã¯2次å
ã®arrayã«ãªã£ã¦ããï¼ç¹å¾´ç¹ãã¨ã«ç¹å¾´éã®ãã¯ãã«ãæ ¼ç´ããã¦ããï¼</p><p>KAZEã§è¨è¿°ããç¹å¾´éã表示ãã¦ã¿ãã¨ãããªæãï¼0çªç®ã®ç¹ï¼ï¼</p>
<pre class="code lang-python" data-lang="python" data-unlink>>>descriptors[<span class="synConstant">0</span>]
array([ -<span class="synConstant">7.38840317e-04</span>, -<span class="synConstant">6.34267868e-04</span>, <span class="synConstant">2.61819176e-03</span>,
<span class="synConstant">3.50267510e-03</span>, -<span class="synConstant">1.59906253e-04</span>, -<span class="synConstant">4.56994586e-03</span>,
<span class="synConstant">4.39605350e-03</span>, <span class="synConstant">9.44076758e-03</span>, -<span class="synConstant">1.75689301e-03</span>,
<span class="synConstant">8.05667194e-04</span>, <span class="synConstant">3.55383591e-03</span>, <span class="synConstant">4.12554527e-03</span>,
-<span class="synConstant">1.54193444e-03</span>, <span class="synConstant">1.58668880e-03</span>, <span class="synConstant">2.78847502e-03</span>,
<span class="synConstant">3.14337271e-03</span>, -<span class="synConstant">1.62520558e-02</span>, <span class="synConstant">1.65848620e-02</span>,
<span class="synConstant">3.65739577e-02</span>, <span class="synConstant">2.07063138e-01</span>, <span class="synConstant">2.64649391e-02</span>,
-<span class="synConstant">6.13974873e-03</span>, <span class="synConstant">9.64385048e-02</span>, <span class="synConstant">2.91850477e-01</span>,
<span class="synConstant">5.54781593e-02</span>, <span class="synConstant">6.74537197e-03</span>, <span class="synConstant">6.74520805e-02</span>,
<span class="synConstant">8.45865980e-02</span>, -<span class="synConstant">2.12559430e-03</span>, <span class="synConstant">1.18403265e-03</span>,
<span class="synConstant">5.09992335e-03</span>, <span class="synConstant">4.04977519e-03</span>, -<span class="synConstant">1.28035052e-02</span>,
<span class="synConstant">6.93068025e-04</span>, <span class="synConstant">3.93203236e-02</span>, <span class="synConstant">4.54802722e-01</span>,
-<span class="synConstant">2.96720478e-04</span>, <span class="synConstant">6.83288351e-02</span>, <span class="synConstant">8.15773308e-02</span>,
<span class="synConstant">6.17026806e-01</span>, -<span class="synConstant">1.08468741e-01</span>, <span class="synConstant">5.95125668e-02</span>,
<span class="synConstant">1.92962006e-01</span>, <span class="synConstant">2.17324436e-01</span>, -<span class="synConstant">1.21422755e-02</span>,
<span class="synConstant">2.50244630e-03</span>, <span class="synConstant">1.34693161e-02</span>, <span class="synConstant">6.25377288e-03</span>,
<span class="synConstant">2.55310140e-03</span>, -<span class="synConstant">4.21544649e-02</span>, <span class="synConstant">2.98030730e-02</span>,
<span class="synConstant">1.50349155e-01</span>, <span class="synConstant">4.27789390e-02</span>, -<span class="synConstant">9.73087847e-02</span>,
<span class="synConstant">1.63991615e-01</span>, <span class="synConstant">1.90487400e-01</span>, <span class="synConstant">3.39032081e-03</span>,
-<span class="synConstant">2.32313443e-02</span>, <span class="synConstant">1.98113456e-01</span>, <span class="synConstant">6.58137947e-02</span>,
-<span class="synConstant">1.16498368e-02</span>, <span class="synConstant">2.66303378e-03</span>, <span class="synConstant">1.25482017e-02</span>,
<span class="synConstant">4.14769724e-03</span>], dtype=float32)
</pre><p>ã°ã©ã表示ã ã¨ãããªæãï¼</p>
<pre class="code lang-python" data-lang="python" data-unlink><span class="synPreProc">import</span> matplotlib.pyplot <span class="synStatement">as</span> plt
plt.plot(descriptors[<span class="synConstant">0</span>])
</pre><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141201/20141201234637.png" alt="f:id:whoopsidaisies:20141201234637p:plain" title="f:id:whoopsidaisies:20141201234637p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>KAZEã¯64次å
ã®å®æ°ãã¯ãã«ã§ç¹å¾´éè¨è¿°ãããã®ã§ä»¥ä¸ã®ããã«ãªããï¼è¨è¿°åã«ãã£ã¦ãã¼ã¿éãéãããé
åã®é·ããåãå¤ãã£ã¦ããï¼</p>
</div>
whoopsidaisies
Python+OpenCVã§ç¹å¾´ç¹æ½åºã»ä½¿ããã¢ã«ã´ãªãºã ã¾ã¨ã OpenCV2.4.9ã¨3.0 alpha
hatenablog://entry/8454420450075787134
2014-12-01T03:12:13+09:00
2014-12-01T03:12:13+09:00 軽éããã°ã©ãã³ã°è¨èªãè¦æãªã®ã§æ¬é ãã¦ãããï¼ä¸éã§ã¯PythonããOpenCVãå¼ã¶ã®ãæµè¡ã£ã¦ãããããªã®ã§ï¼ç·´ç¿ãã¦ãOpenCVã§ä½¿ããç¹å¾´ç¹æ½åºã¢ã«ã´ãªãºã ãã¾ã¨ãã¦ã¿ãï¼OpenCV2.4.9ã¨OpenCV3.0 alphaã«ã¤ãã¦ã¾ã¨ããï¼3.0 betaã¯ãªããåããªãã£ãã®ã§ãã¤ãæãããã°èª¿æ»ï¼ ç°å¢ Windowsã§OpenCVå
¬å¼ãµã¤ãã®ãã¦ã³ãã¼ããã¼ã¸ãã2.4.9ããã³3.0 alphaã®ãã«ãæ¸ã¿ãã¤ããªããã¦ã³ãã¼ããã¦ãã¦è§£åãããã®ã使ãï¼Pythonããã®OpenCVã®å¼ã³åºãæ¹ã¯ããã¨ããåç
§ï¼ ç¹å¾´ç¹æ½åºã®ä½¿ãæ¹ OpenCVã§å®è£
ããã¦ããç¹â¦
<p>軽éããã°ã©ãã³ã°è¨èªãè¦æãªã®ã§æ¬é ãã¦ãããï¼ä¸éã§ã¯PythonããOpenCVãå¼ã¶ã®ãæµè¡ã£ã¦ãããããªã®ã§ï¼ç·´ç¿ãã¦ãOpenCVã§ä½¿ããç¹å¾´ç¹æ½åºã¢ã«ã´ãªãºã ãã¾ã¨ãã¦ã¿ãï¼</p><p>OpenCV2.4.9ã¨OpenCV3.0 alphaã«ã¤ãã¦ã¾ã¨ããï¼3.0 betaã¯ãªããåããªãã£ãã®ã§ãã¤ãæãããã°èª¿æ»ï¼</p>
<div class="section">
<h3>ç°å¢</h3>
<p>Windowsã§OpenCVå
¬å¼ãµã¤ãã®<a href="http://opencv.org/downloads.html">ダウンロードページ</a>ãã<a href="https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.9/opencv-2.4.9.exe/download">2.4.9</a>ããã³<a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0-alpha/">3.0 alpha</a>ã®ãã«ãæ¸ã¿ãã¤ããªããã¦ã³ãã¼ããã¦ãã¦è§£åãããã®ã使ãï¼</p><p>Pythonããã®OpenCVã®å¼ã³åºãæ¹ã¯<a href="http://docs.opencv.org/trunk/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.html">こことか</a>ãåç
§ï¼</p>
</div>
<div class="section">
<h3>ç¹å¾´ç¹æ½åºã®ä½¿ãæ¹</h3>
<p>OpenCVã§å®è£
ããã¦ããç¹å¾´ç¹æ½åºã®ã¢ã«ã´ãªãºã ã¯ããã¤ããããï¼FeatureDetectorã¨ããå
±éã¤ã³ã¿ã¼ãã§ã¼ã¹ã使ããã¨ã§ã©ã®ã¢ã«ã´ãªãºã ã§ãåæ§ã®è¨è¿°ã§ä½¿ããï¼ä½¿ãæ¹ã¯ä»¥ä¸ï¼</p>
<pre class="code lang-python" data-lang="python" data-unlink><span class="synComment"># ç»åèªã¿è¾¼ã¿</span>
img = cv2.imread(<span class="synConstant">'gazou.bmp'</span>)
<span class="synComment"># FeatureDetectorã®ã¤ã³ã¹ã¿ã³ã¹ãçæ</span>
detector = cv2.FeatureDetector_create(detector_type)
<span class="synComment"># ç¹å¾´ç¹ãæ½åº</span>
keypoints = detctor.detect(img)
</pre><p>FeatureDetector_createã¡ã½ããã®å¼æ°ã«ã¢ã«ã´ãªãºã åãæååã§æ¸¡ããã¨ã§ï¼ã©ã®ã¢ã«ã´ãªãºã ã§ç¹å¾´ç¹æ½åºããããé¸æãããã¨ãåºæ¥ãï¼ä¾ãã°ï¼ORBã¢ã«ã´ãªãºã ã§ç¹å¾´ç¹ãæ½åºãã¦è¡¨ç¤ºããã®ã¯ä»¥ä¸ã®ããã«ãªãï¼</p>
<pre class="code lang-python" data-lang="python" data-unlink><span class="synPreProc">import</span> cv2
img = cv2.imread(<span class="synConstant">'gazou.bmp'</span>)
<span class="synComment"># ã¢ã«ã´ãªãºã åãå¼æ°ã§æ¸¡ã</span>
detector = cv2.FeatureDetector_create(<span class="synConstant">'ORB'</span>)
keypoints = detctor.detect(img)
<span class="synComment"># ç»åã¸ã®ç¹å¾´ç¹ã®æ¸ãè¾¼ã¿</span>
out = cv2.drawKeypoints(img, keypoints, <span class="synIdentifier">None</span>)
<span class="synComment"># 表示</span>
cv2.imshow(name, out)
cv2.waitKey(<span class="synConstant">0</span>)
</pre><p>çµæã¯ä»¥ä¸ã®ããã«ãªãï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141201/20141201024751.png" alt="f:id:whoopsidaisies:20141201024751p:plain" title="f:id:whoopsidaisies:20141201024751p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>ã¡ãªã¿ã«ç¹å¾´ç¹ã®æ¸ãè¾¼ã¿é¨åã以ä¸ã®ããã«ããã¨ï¼ç¹å¾´ç¹ã®ãµã¤ãºã¨æ¹åã表ãåãæç»ãããï¼</p>
<pre class="code lang-python" data-lang="python" data-unlink>out = cv2.drawKeypoints(img, keypoints, <span class="synIdentifier">None</span>, <span class="synIdentifier">None</span>, cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
</pre><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141201/20141201024104.png" alt="f:id:whoopsidaisies:20141201024104p:plain" title="f:id:whoopsidaisies:20141201024104p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>FeatureDetectorã¤ã³ã¿ã¼ãã§ã¼ã¹ã§ä½¿ããã¢ã«ã´ãªãºã </h3>
<p>FeatureDetectorã¤ã³ã¿ã¼ãã§ã¼ã¹ã§æå®ã§ããç¹å¾´ç¹æ½åºã¢ã«ã´ãªãºã ã¯OpenCVã®ãã¼ã¸ã§ã³ã§å¤ãããããªã®ã§ï¼OpenCV2.4.9ã§ä½¿ãããã®ã¨OpenCV3.0 alphaã§ä½¿ãããã®ã以ä¸ã«ã¾ã¨ããï¼<br />
<br />
</p>
<table>
<tr>
<td>ãã¼ã¸ã§ã³</td>
<th>ã¢ã«ã´ãªãºã å</th>
</tr>
<tr>
<th>2.4.9</th>
<td>BRISK, Dense, FAST, FASTX, GFTT, HARRIS, MSER, ORB, SIFT, STAR, SURF, SURF_OCL, SimpleBlob</td>
</tr>
<tr>
<th>3.0 alpha</th>
<td>AKAZE, BRISK, FAST, GFTT, HARRIS, KAZE, MSER, ORB, SimpleBlob</td>
</tr>
</table><p><br />
C++çã«ã¤ãã¦ã¯ä»¥ä¸ã®è¨äºã«ã¾ã¨ãã¦ããï¼<br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2014/08/20/200215"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2014%2F08%2F20%2F200215" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2014/08/20/200215">OpenCV3.0.0-alphaの特徴抽出・マッチングまとめ - whoopsidaisies's diary</a><br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/07/135810"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2013%2F12%2F07%2F135810" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/07/135810">OpenCVで画像の特徴抽出・マッチングを行う - whoopsidaisies's diary</a></p>
</div>
whoopsidaisies
C#ã§ç»åãWaveletå¤æ Accord.NET
hatenablog://entry/8454420450075706497
2014-11-30T10:32:21+09:00
2014-11-30T10:32:21+09:00 C#ã§ç»åã®Waveletå¤æãè¡ãï¼ã³ã³ãã¥ã¼ã¿ãã¸ã§ã³çã®.NETåãã®ãªã¼ãã³ã½ã¼ã¹ã®ã©ã¤ãã©ãªã§ããAccord.NET Frameworkã使ãï¼ Accord.NETã®ã¤ã³ã¹ãã¼ã« NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããAccord.Imagingããæ¤ç´¢ã»ã¤ã³ã¹ãã¼ã«ï¼ WaveletTransformã¯ã©ã¹ Accord.NETã®WaveletTransformã¯ã©ã¹ã«ãã£ã¦Waveletå¤æãè¡ããï¼å
¥åç»åã¯ã°ã¬ã¼ã¹ã±ã¼ã«ã§ï¼è§£å度ã2ã®ã¹ãä¹ã§ãªãã¨ãããªãï¼ ã½ã¼ã¹ã³ã¼ã WaveletTâ¦
<p>C#ã§ç»åã®Waveletå¤æãè¡ãï¼ã³ã³ãã¥ã¼ã¿ãã¸ã§ã³çã®.NETåãã®ãªã¼ãã³ã½ã¼ã¹ã®ã©ã¤ãã©ãªã§ãã<a href="http://accord-framework.net/">Accord.NET Framework</a>ã使ãï¼</p>
<div class="section">
<h3>Accord.NETã®ã¤ã³ã¹ãã¼ã«</h3>
<p>NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããAccord.Imagingããæ¤ç´¢ã»ã¤ã³ã¹ãã¼ã«ï¼</p>
</div>
<div class="section">
<h3>WaveletTransformã¯ã©ã¹</h3>
<p>Accord.NETã®<a href="http://accord-framework.net/docs/html/T_Accord_Imaging_Filters_WaveletTransform.htm">WaveletTransform</a>ã¯ã©ã¹ã«ãã£ã¦Waveletå¤æãè¡ããï¼å
¥åç»åã¯ã°ã¬ã¼ã¹ã±ã¼ã«ã§ï¼è§£å度ã2ã®ã¹ãä¹ã§ãªãã¨ãããªãï¼</p>
</div>
<div class="section">
<h3>ã½ã¼ã¹ã³ã¼ã</h3>
<p>WaveletTransformã¯ã©ã¹ã®åæåæã«Waveletæ¯é¢æ°ãæå®ããï¼ãã®å¼æ°ã§Waveletå¤æã®ã¬ãã«ãæå®ã§ããï¼ããã§ã¯Haaré¢æ°ã§ã¬ãã«2ã¨ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// å
¥åç»å</span>
var img = <span class="synStatement">new</span> Bitmap(<span class="synSpecial">@</span><span class="synConstant">"Penguins.jpg"</span>);
<span class="synComment">// ç»åã®è§£å度ã2ã®ã¹ãä¹ã«ãªãããã«èª¿æ´</span>
var bitWidth = Convert.ToString(img.Width - <span class="synConstant">1</span>, <span class="synConstant">2</span>).Length;
var bitHeight = Convert.ToString(img.Height - <span class="synConstant">1</span>, <span class="synConstant">2</span>).Length;
var width = (<span class="synType">int</span>)Math.Pow(<span class="synConstant">2</span>, bitWidth);
var height = (<span class="synType">int</span>)Math.Pow(<span class="synConstant">2</span>, bitHeight);
<span class="synComment">// ééã®é¨åã¯ã¼ãåã</span>
var imgPadded = <span class="synStatement">new</span> Bitmap(width, height, img.PixelFormat);
var graphics = Graphics.FromImage(imgPadded);
graphics.DrawImage(img, <span class="synConstant">0</span>, <span class="synConstant">0</span>);
graphics.Dispose();
<span class="synComment">// ã°ã¬ã¼ã¹ã±ã¼ã«å</span>
var gray = <span class="synStatement">new</span> AForge.Imaging.Filters.Grayscale(<span class="synConstant">0.2125</span>, <span class="synConstant">0.7154</span>, <span class="synConstant">0.0721</span>).Apply(imgPadded);
<span class="synComment">// Waveletå¤æã¯ã©ã¹ã®ä½æ</span>
<span class="synComment">// Harrã¯ã©ã¹ã®åæåæã«ã¬ãã«ãæå®åºæ¥ã</span>
var wavelet = <span class="synStatement">new</span> Accord.Imaging.Filters.WaveletTransform(<span class="synStatement">new</span> Accord.Math.Wavelets.Haar(<span class="synConstant">2</span>));
<span class="synComment">// Waveletå¤æ</span>
var imgWavelet = wavelet.Apply(gray);
pictureBox1.Image = imgWavelet;
</pre>
</div>
<div class="section">
<h3>çµæ</h3>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141130/20141130095415.png" alt="f:id:whoopsidaisies:20141130095415p:plain" title="f:id:whoopsidaisies:20141130095415p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>éå¤æ</h3>
<p>WaveletTransformã¯ã©ã¹ã®<a href="http://accord-framework.net/docs/html/P_Accord_Imaging_Filters_WaveletTransform_Backward.htm">Backword</a>ããããã£ãtrueã«ãã¦Applyã¡ã½ãããå®è¡ããã¨éå¤æãåºæ¥ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>wavelet.Backward = <span class="synConstant">true</span>;
var gyaku = wavelet.Apply(imgWavelet);
</pre>
</div>
whoopsidaisies
C#ã§ç»åãé«éãã¼ãªã¨å¤æãAForge.NET
hatenablog://entry/8454420450075684932
2014-11-30T09:19:05+09:00
2014-11-30T09:19:05+09:00 C#ã§ç»åã®é«éãã¼ãªã¨å¤æï¼FFTï¼ãè¡ãï¼ã³ã³ãã¥ã¼ã¿ãã¸ã§ã³çã®ã©ã¤ãã©ãªã§ããAForge.NET Frameworkã使ãï¼ AForge.NETã®ã¤ã³ã¹ãã¼ã« Nugetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããAForgeãã§æ¤ç´¢ï¼ãAForge.Imagingããé¸æãã¦ã¤ã³ã¹ãã¼ã«ï¼ ComplexImageã¯ã©ã¹ AForge.NETã®ComplexImageã¯ã©ã¹ã使ãã¨ç»åã®FFTããã³éFFTãåºæ¥ãï¼å
¥åããç»åã¯ã°ã¬ã¼ã¹ã±ã¼ã«ã§è§£å度ã2ã®ã¹ãä¹ã«ãªã£ã¦ããå¿
è¦ãããï¼ ã½ã¼ã¹ã³ã¼ã ç»åã®ã°ã¬ã¼â¦
<p>C#ã§ç»åã®é«éãã¼ãªã¨å¤æï¼FFTï¼ãè¡ãï¼ã³ã³ãã¥ã¼ã¿ãã¸ã§ã³çã®ã©ã¤ãã©ãªã§ãã<a href="https://code.google.com/p/aforge/">AForge.NET Framework</a>ã使ãï¼</p>
<div class="section">
<h3>AForge.NETã®ã¤ã³ã¹ãã¼ã«</h3>
<p>Nugetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããAForgeãã§æ¤ç´¢ï¼ãAForge.Imagingããé¸æãã¦ã¤ã³ã¹ãã¼ã«ï¼</p>
</div>
<div class="section">
<h3>ComplexImageã¯ã©ã¹</h3>
<p>AForge.NETã®<a href="http://www.aforgenet.com/framework/docs/html/8ec218c8-628b-e6b9-c398-3d65f14280d5.htm">ComplexImage</a>ã¯ã©ã¹ã使ãã¨ç»åã®FFTããã³éFFTãåºæ¥ãï¼å
¥åããç»åã¯ã°ã¬ã¼ã¹ã±ã¼ã«ã§è§£å度ã2ã®ã¹ãä¹ã«ãªã£ã¦ããå¿
è¦ãããï¼</p>
</div>
<div class="section">
<h3>ã½ã¼ã¹ã³ã¼ã</h3>
<p>ç»åã®ã°ã¬ã¼ã¹ã±ã¼ã«åã¯<a href="http://www.aforgenet.com/framework/docs/html/d7196dc6-8176-4344-a505-e7ade35c1741.htm">Grayscale</a>ã¯ã©ã¹ã使ã£ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// å
¥åç»å</span>
var img = <span class="synStatement">new</span> Bitmap(<span class="synSpecial">@</span><span class="synConstant">"Lighthouse.jpg"</span>);
pictureBox1.Image = img;
<span class="synComment">// ç»åã®è§£å度ã2ã®ã¹ãä¹ã«ãªãããã«èª¿æ´</span>
var bitWidth = Convert.ToString(img.Width - <span class="synConstant">1</span>, <span class="synConstant">2</span>).Length;
var bitHeight = Convert.ToString(img.Height - <span class="synConstant">1</span>, <span class="synConstant">2</span>).Length;
var width = (<span class="synType">int</span>)Math.Pow(<span class="synConstant">2</span>, bitWidth);
var height = (<span class="synType">int</span>)Math.Pow(<span class="synConstant">2</span>, bitHeight);
<span class="synComment">// ééã®é¨åã¯ã¼ãåã</span>
var imgPadded = <span class="synStatement">new</span> Bitmap(width, height, img.PixelFormat);
var graphics = Graphics.FromImage(imgPadded);
graphics.DrawImage(img, <span class="synConstant">0</span>, <span class="synConstant">0</span>);
graphics.Dispose();
<span class="synComment">// ã°ã¬ã¼ã¹ã±ã¼ã«å</span>
var gray = <span class="synStatement">new</span> AForge.Imaging.Filters.Grayscale(<span class="synConstant">0.2125</span>, <span class="synConstant">0.7154</span>, <span class="synConstant">0.0721</span>).Apply(imgPadded);
pictureBox2.Image = gray;
<span class="synComment">// FFT</span>
var complexImage = AForge.Imaging.ComplexImage.FromBitmap(gray);
complexImage.ForwardFourierTransform();
pictureBox3.Image = complexImage.ToBitmap();
</pre>
</div>
<div class="section">
<h3>çµæç»å</h3>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141130/20141130083904.png" alt="f:id:whoopsidaisies:20141130083904p:plain" title="f:id:whoopsidaisies:20141130083904p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>FFTå¾ã®å¤</h3>
<p>ComplexImageã¯ã©ã¹ã®<a href="http://www.aforgenet.com/framework/docs/html/5717ee01-e66e-d13d-8578-bdcc862e033f.htm">Data</a>ããããã£ã¯2次å
é
åã§FFTå¾ã®å¤ãæ ¼ç´ããã¦ããï¼ã¾ãï¼<a href="http://www.aforgenet.com/framework/docs/html/bf07655f-4048-c890-190a-16859beb1925.htm">BackwardFourierTransform</a>ã¡ã½ããã§éFFTãè¡ããï¼</p>
</div>
whoopsidaisies
Visual Studioã§ãããã°æã«OpenCVã®Matçã®ç»åã表示ã§ãããã©ã°ã¤ã³ã便å©
hatenablog://entry/8454420450075550903
2014-11-28T17:56:37+09:00
2014-11-28T17:56:37+09:00 OpenCVå
¬å¼ãµã¤ãã®NEWSãè¦ã¦ãããImage Watch plugin for Visual Studioãã¨ããã®ãè¦ã¤ããï¼ä½¿ã£ã¦ã¿ãã便å©ããã ã£ãã®ã§ã¡ã¢ï¼ãã£ã¨æ©ãç¥ãããã£ãï¼ããããimshowã¨ãã®ã³ã¼ãã追å ãã¦ã¦ã£ã³ãã¦ã表示ãããªãã¦ãMatã®ä¸ã®ç»åã確èªã§ããï¼ã¾ãï¼æ¡å¤§è¡¨ç¤ºã¨ãç»ç´ å¤ã®è¡¨ç¤ºãåºæ¥ãããé常ã®OpenCVã®ç»å表示ç¨ã®ã¦ã£ã³ãã¦ãã便å©ãªæ°ãããï¼ Image Watch plugin for Visual Studioã®ã¤ã³ã¹ãã¼ã« 以ä¸ã®ãµã¤ããããã¦ã³ãã¼ããã¦ãã¦æ示ã«ãããã£ã¦ã¤ã³ã¹ãã¼ã«ããã ãï¼ Image Watch exteâ¦
<p><a href="http://opencv.org/image-watch-plugin-for-visual-studio.html">OpenCV公式サイトのNEWS</a>ãè¦ã¦ããã<a href="https://visualstudiogallery.msdn.microsoft.com/e682d542-7ef3-402c-b857-bbfba714f78d">Image Watch plugin for Visual Studio</a>ãã¨ããã®ãè¦ã¤ããï¼ä½¿ã£ã¦ã¿ãã便å©ããã ã£ãã®ã§ã¡ã¢ï¼ãã£ã¨æ©ãç¥ãããã£ãï¼</p><p>ããããimshowã¨ãã®ã³ã¼ãã追å ãã¦ã¦ã£ã³ãã¦ã表示ãããªãã¦ãMatã®ä¸ã®ç»åã確èªã§ããï¼ã¾ãï¼æ¡å¤§è¡¨ç¤ºã¨ãç»ç´ å¤ã®è¡¨ç¤ºãåºæ¥ãããé常ã®OpenCVã®ç»å表示ç¨ã®ã¦ã£ã³ãã¦ãã便å©ãªæ°ãããï¼</p>
<div class="section">
<h3>Image Watch plugin for Visual Studioã®ã¤ã³ã¹ãã¼ã«</h3>
<p>以ä¸ã®ãµã¤ããããã¦ã³ãã¼ããã¦ãã¦æ示ã«ãããã£ã¦ã¤ã³ã¹ãã¼ã«ããã ãï¼<br />
<a href="https://visualstudiogallery.msdn.microsoft.com/e682d542-7ef3-402c-b857-bbfba714f78d"><img src="http://cdn-ak.favicon.st-hatena.com/?url=https%3A%2F%2Fvisualstudiogallery.msdn.microsoft.com%2Fe682d542-7ef3-402c-b857-bbfba714f78d" alt="" class="http-favicon" /></a><a href="https://visualstudiogallery.msdn.microsoft.com/e682d542-7ef3-402c-b857-bbfba714f78d">Image Watch extension</a></p><p>以ä¸ã®ãµã¤ãã«è©³ããæé çè¼ã£ã¦ã¾ãï¼<br />
<a href="http://www.atinfinity.info/blog/archives/1601"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwww.atinfinity.info%2Fblog%2Farchives%2F1601" alt="" class="http-favicon" /></a><a href="http://www.atinfinity.info/blog/archives/1601">Image Watchの使い方 | dandelion's log</a><br />
</p>
</div>
<div class="section">
<h3>使ã£ã¦ã¿ã</h3>
<p>以ä¸ã®ã³ã¼ãã§è©¦ãã¦ã¿ãï¼ç»åã表示ãããããã®ã³ã¼ãã¯ç¹ã«å¿
è¦ãªãï¼ç»åãå
¥ã£ã¦ããå¤æ°ãããã°èªåã§è¡¨ç¤ºãã¦ãããï¼</p>
<pre class="code lang-cpp" data-lang="cpp" data-unlink><span class="synPreProc">#include </span><span class="synConstant"><opencv2/opencv.hpp></span>
<span class="synStatement">using</span> <span class="synType">namespace</span> cv;
<span class="synType">void</span> main()
{
<span class="synComment">// ç»åèªã¿è¾¼ã¿</span>
Mat img = imread(<span class="synConstant">"Penguins.jpg"</span>);
<span class="synComment">// Sobelãã£ã«ã¿</span>
Mat imgSobel;
Sobel(img, imgSobel, img.depth(), <span class="synConstant">1</span>, <span class="synConstant">1</span>);
<span class="synComment">// ã©ãã©ã·ã¢ã³ãã£ã«ã¿</span>
Mat imgLaplacian;
Laplacian(img, imgLaplacian, img.depth());
<span class="synComment">// Cannyã¢ã«ã´ãªãºã </span>
Mat imgCanny;
Canny(img, imgCanny, <span class="synConstant">50</span>, <span class="synConstant">200</span>);
}
</pre><p>ä¸çªä¸ã®è¡ã«ãã¬ã¼ã¯ãã¤ã³ããç½®ãã¦ï¼ãããã°å®è¡ãã¦æ¢ããï¼</p><p>ã表示ãã¡ãã¥ã¼ã®ä¸ãããImage Watchããæ¢ãã¦ã¯ãªãã¯ãã¦ã¦ã£ã³ãã¦ã表示ãããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141128/20141128173607.png" alt="f:id:whoopsidaisies:20141128173607p:plain" title="f:id:whoopsidaisies:20141128173607p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>ããããã¨ä»¥ä¸ã®æ§ãªã¦ã£ã³ãã¦ãåºã¦ãã¦ï¼Matåã®å¤æ°ã¨ãã®ä¸èº«ã®ç»åã表示ãããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141128/20141128165602.png" alt="f:id:whoopsidaisies:20141128165602p:plain" title="f:id:whoopsidaisies:20141128165602p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>å·¦å´ã«ç»åä¸è¦§ãããã®ã§ï¼ã¯ãªãã¯ããã°ä»¥ä¸ã®ããã«ãã®ç»åã表示ãããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141128/20141128165507.png" alt="f:id:whoopsidaisies:20141128165507p:plain" title="f:id:whoopsidaisies:20141128165507p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>ãã¦ã¹ã¹ã¯ãã¼ã«ã§æ¡å¤§å¯è½ï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141128/20141128173940.png" alt="f:id:whoopsidaisies:20141128173940p:plain" title="f:id:whoopsidaisies:20141128173940p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>æ大ã¾ã§æ¡å¤§ããã¨åç»ç´ ã®ç»ç´ å¤ãæ°åã§è¡¨ç¤ºãããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141128/20141128174024.png" alt="f:id:whoopsidaisies:20141128174024p:plain" title="f:id:whoopsidaisies:20141128174024p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>ç»ç´ ãå³ã¯ãªãã¯ãããï¼ãã®ç»ç´ ã®ã¢ãã¬ã¹ã®ã³ãã¼ã¨ããåºæ¥ããããï¼</p><p>以ä¸ã®ããã«OpenCVã®Matã®ä¸ã®ç»åãç°¡åã«ç¢ºèªã§ããã®ã§ï¼Visual Studioã§OpenCVã使ãå ´åã¯ããªã便å©ã ã¨æãï¼</p><p>試ãã¦ãªããã©<a href="https://visualstudiogallery.msdn.microsoft.com/e682d542-7ef3-402c-b857-bbfba714f78d">配布サイト</a>ã®èª¬æã«ããã¨ï¼cv::Mat_<>, CvMat, _IplImageãªããã«ã対å¿ãã¦ãããããï¼</p>
</div>
whoopsidaisies
opencvã§æåèªèãã®ï¼ãTesseractã©ãã
hatenablog://entry/12921228815733154180
2014-11-12T00:31:00+09:00
2014-11-12T00:31:00+09:00 OpenCV3.0ç³»ããæåèªèã¢ã¸ã¥ã¼ã«ãæè¼ããããããªã®ã§ä½¿ã£ã¦ã¿ãï¼ç¾ç¶ã®3.0 alphaã3.0 betaã§ã¯ï¼æåèªèã¢ã¸ã¥ã¼ã«ã¯ã¡ã¤ã³ã¬ãã¸ããªã«çµã¿è¾¼ã¾ãã¦ãããéçºç¨ã¬ãã¸ããªã®opencv_contribã®æ¹ã«å
¥ã£ã¦ããããã§ï¼opencv_contribã¨ä¸ç·ã«OpenCVããã«ãããå¿
è¦ãããï¼ OpenCVã®æåèªèã¢ã¸ã¥ã¼ã« OpenCVã®ããã¥ã¡ã³ãã«ããã¨ï¼ä»¥ä¸ã®ï¼ç¨®é¡ã®æåèªèæ¹æ³ããããããï¼ ãªã¼ãã³ã½ã¼ã¹ã®OCRã©ã¤ãã©ãªtesseract-ocrãå¼ã³åºãæ¹æ³ é ããã«ã³ãã¢ãã«ã«ããèªèæ¹æ³ ä»åã¯ï¼1ã®æ¹æ³ã«ã¤ãã¦è©¦ãã¦ã¿ãï¼ æåèªèã¢ã¸ã¥ã¼ã«â¦
<p><a href="http://opencv.org/opencv-3-0-alpha.html">OpenCV3.0系から文字認識モジュールが搭載される</a>ãããªã®ã§ä½¿ã£ã¦ã¿ãï¼ç¾ç¶ã®3.0 alphaã3.0 betaã§ã¯ï¼æåèªèã¢ã¸ã¥ã¼ã«ã¯ã¡ã¤ã³ã¬ãã¸ããªã«çµã¿è¾¼ã¾ãã¦ãããéçºç¨ã¬ãã¸ããªã®<a href="https://github.com/itseez/opencv_contrib">opencv_contrib</a>ã®æ¹ã«å
¥ã£ã¦ããããã§ï¼opencv_contribã¨ä¸ç·ã«OpenCVããã«ãããå¿
è¦ãããï¼</p>
<div class="section">
<h3>OpenCVã®æåèªèã¢ã¸ã¥ã¼ã«</h3>
<p><a href="http://docs.opencv.org/trunk/modules/text/doc/ocr.html">OpenCVのドキュメント</a>ã«ããã¨ï¼ä»¥ä¸ã®ï¼ç¨®é¡ã®æåèªèæ¹æ³ããããããï¼</p>
<ol>
<li>ãªã¼ãã³ã½ã¼ã¹ã®OCRã©ã¤ãã©ãª<a href="https://code.google.com/p/tesseract-ocr/">tesseract-ocr</a>ãå¼ã³åºãæ¹æ³</li>
<li><a href="http://cmp.felk.cvut.cz/~neumalu1/icdar2011_article.pdf">隠れマルコフモデルによる認識方法</a></li>
</ol><p>ä»åã¯ï¼1ã®æ¹æ³ã«ã¤ãã¦è©¦ãã¦ã¿ãï¼</p>
</div>
<div class="section">
<h3>æåèªèã¢ã¸ã¥ã¼ã«ã®æºå</h3>
<div class="section">
<h4>tesseract-ocrã®ãã¦ã³ãã¼ã</h4>
<p><a href="https://code.google.com/p/tesseract-ocr/downloads/list">https://code.google.com/p/tesseract-ocr/downloads/list</a>ããVC++ããtesseract-ocrãå¼ã³åºãç¨ã®ã©ã¤ãã©ãªããã¦ã³ãã¼ãã»è§£åããï¼ãtesseract-3.xx.xx-win32-lib-include-dirs.zipãã£ã¦ååã®ãã¤ï¼ä»åã¯ã<a href="https://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-3.02.02-win32-lib-include-dirs.zip&can=2&q=">tesseract-3.02.02-win32-lib-include-dirs.zip</a>ãã使ã£ãï¼</p><p><a href="https://code.google.com/p/tesseract-ocr/downloads/list">https://code.google.com/p/tesseract-ocr/downloads/list</a>ããtesseract-ocrç¨ã®å¦ç¿æ¸ã¿ã®ãã¼ã¿ãã¡ã¤ã«ããã¦ã³ãã¼ããã¦ããï¼ä»åã¯è±èªã§è©¦ãããã<a href="https://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-ocr-3.02.eng.tar.gz&can=2&q=">tesseract-ocr-3.02.eng.tar.gz</a>ãããã¦ã³ãã¼ãã»è§£åããï¼</p>
</div>
<div class="section">
<h4>opencv_contribã®ãã¦ã³ãã¼ã</h4>
<p><a href="https://github.com/itseez/opencv_contrib">https://github.com/itseez/opencv_contrib</a>ããopencv_contribããã¦ã³ãã¼ãã»è§£åããï¼</p>
</div>
<div class="section">
<h4>OpenCVã®ãã«ã</h4>
<p>CMakeã使ã£ã¦ãã«ãããï¼<a href="http://www.buildinsider.net/small/opencv/02#cmake">ここらへん</a>ãåèã«ï¼</p><p>ãOPENCV_EXTRA_MODULES_PATHããã©ã¡ã¼ã¿ã®å¤ãã(opencv_contribã®ãã¹)/modulesãã«ã»ãããã¦Configureããï¼</p><p>ããã¨ãTesseract_INCLUDE_DIRãã¨ãTesseract_LIBRARYãã¨ãããã©ã¡ã¼ã¿ãåºã¦ããã®ã§</p>
<ul>
<li>Tesseract_INCLUDE_DIR â (tesseract-ocrã®ãã¹)/include</li>
<li>Tesseract_LIBRARY â (tesseract-ocrã®ãã¹)/lib</li>
</ul><p>ã¨ã»ããããï¼</p><p>以ä¸ã®è¨å®ã§Generateãã¦OpenCVããã«ãããã¨æåèªèã¢ã¸ã¥ã¼ã«ãçµã¿è¾¼ã¾ããï¼ã§ï¼ã¤ã³ã¹ãã¼ã«ããï¼</p>
</div>
</div>
<div class="section">
<h3>åä½ç¢ºèª</h3>
<p>å®éã«ç»åãå
¥åãã¦ãã£ã¦ã¿ãã½ã¼ã¹ã³ã¼ãã¨çµæã以ä¸ï¼OpenCVã®Matå½¢å¼ã®ç»åã使ã£ã¦æåèªèåºæ¥ãããï¼<a href="https://code.google.com/p/tesseract-ocr/wiki/APIExample">tesseract-ocrのAPI直接叩く</a>ããã¯ä½¿ããããã¨æãï¼</p><p>追è¨ï¼æåã®ããã¾ãã®ä½ç½®ã®åºåãééã£ã¦ããããã½ã¼ã¹ã³ã¼ãã¨çµæç»åãä¿®æ£ããï¼</p>
<div class="section">
<h5>ã½ã¼ã¹ã³ã¼ã</h5>
<pre class="code lang-cpp" data-lang="cpp" data-unlink><span class="synPreProc">#include </span><span class="synConstant"><opencv2/opencv.hpp></span>
<span class="synPreProc">#include </span><span class="synConstant"><opencv2/text.hpp></span>
<span class="synType">void</span> main()
{
<span class="synComment">// ç»åèªã¿è¾¼ã¿</span>
<span class="synType">auto</span> image = cv::imread(<span class="synConstant">"moji.jpg"</span>);
<span class="synComment">// ã°ã¬ã¼ã¹ã±ã¼ã«å</span>
cv::Mat gray;
cv::cvtColor(image, gray, COLOR_RGB2GRAY);
<span class="synComment">// æåèªèã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹çæ</span>
<span class="synType">auto</span> ocr = cv::text::OCRTesseract::create(<span class="synConstant">"(è¨èªãã¼ã¿ã®ãã¹)/tessdata"</span>, <span class="synConstant">"eng"</span>);
std::string text;
std::vector<cv::Rect> boxes;
std::vector<std::string> words;
vector<<span class="synType">float</span>> confidences;
<span class="synComment">// æåèªèã®å®è¡</span>
ocr->run(gray, text, &boxes, &words, &confidences);
<span class="synComment">// çµæåºå</span>
printf(<span class="synConstant">"</span><span class="synSpecial">%s\n</span><span class="synConstant">"</span>, text.c_str());
<span class="synComment">// æåã®ããã¾ããã¨ã«åºå</span>
printf(<span class="synConstant">" æå | ä½ç½® | 大ãã | ä¿¡é ¼åº¦</span><span class="synSpecial">\n</span><span class="synConstant">"</span>);
printf(<span class="synConstant">"-----------+------------+------------+----------</span><span class="synSpecial">\n</span><span class="synConstant">"</span>);
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < boxes.size(); i++)
{
printf(<span class="synConstant">"</span><span class="synSpecial">%-10s</span><span class="synConstant"> | (</span><span class="synSpecial">%3d</span><span class="synConstant">, </span><span class="synSpecial">%3d</span><span class="synConstant">) | (</span><span class="synSpecial">%3d</span><span class="synConstant">, </span><span class="synSpecial">%3d</span><span class="synConstant">) | </span><span class="synSpecial">%f\n</span><span class="synConstant">"</span>,
words[i].c_str(),
boxes[i].x, boxes[i].y,
boxes[i].width, boxes[i].height,
confidences[i]);
}
}
</pre>
</div>
<div class="section">
<h5>å®è¡çµæ</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20141112/20141112103657.png" alt="f:id:whoopsidaisies:20141112103657p:plain" title="f:id:whoopsidaisies:20141112103657p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
</div>
whoopsidaisies
C#ã§ç´°ç·å AForge.NET
hatenablog://entry/12921228815732929148
2014-09-15T09:45:49+09:00
2014-09-15T09:45:49+09:00 C#ã§ç»åã®ç´°ç·åå¦çãè¡ã£ã¦ç·ç»åãä½æããï¼ã³ã³ãã¥ã¼ã¿ãã¸ã§ã³çã®ã©ã¤ãã©ãªã§ããAForge.NET Frameworkã«ã¯ï¼ã¢ã«ãã©ãã¸ã¼å¦çãå®è£
ããã¦ããã®ã§ãããå©ç¨ããï¼ç´°ç·åã®ã¢ã«ã´ãªãºã ã¯ä»¥ä¸ã®ãµã¤ãããããåç
§ï¼ ãã¿ã¼ã³èªèã®åå¦çã«å¿
è¦ãªäºå¤ç»åã®ç´°ç·åï¼CodeZine ç´°ç·åã¢ã«ã´ãªãºã ç»åå¦çã½ãªã¥ã¼ã·ã§ã³ technotype AForge.NETã®ã¤ã³ã¹ãã¼ã« Nugetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããAForgeãã§æ¤ç´¢ï¼ãAForge.Imagingããé¸æãã¦ã¤ã³ã¹ãã¼ã«â¦
<p>C#ã§ç»åã®ç´°ç·åå¦çãè¡ã£ã¦ç·ç»åãä½æããï¼ã³ã³ãã¥ã¼ã¿ãã¸ã§ã³çã®ã©ã¤ãã©ãªã§ãã<a href="https://code.google.com/p/aforge/">AForge.NET Framework</a>ã«ã¯ï¼<a href="http://www.aforgenet.com/framework/features/morphology_filters.html">モルフォロジー処理が実装されている</a>ã®ã§ãããå©ç¨ããï¼</p><p>ç´°ç·åã®ã¢ã«ã´ãªãºã ã¯ä»¥ä¸ã®ãµã¤ãããããåç
§ï¼<br />
<a href="http://codezine.jp/article/detail/98"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fcodezine.jp%2Farticle%2Fdetail%2F98" alt="" class="http-favicon" /></a><a href="http://codezine.jp/article/detail/98">パターン認識の前処理に必要な二値画像の細線化:CodeZine</a><br />
<a href="http://imagingsolution.blog107.fc2.com/blog-entry-138.html"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fimagingsolution.blog107.fc2.com%2Fblog-entry-138.html" alt="" class="http-favicon" /></a><a href="http://imagingsolution.blog107.fc2.com/blog-entry-138.html">細線化アルゴリズム 画像処理ソリューション</a><br />
<a href="http://www.technotype.net/tutorial/tutorial.php?fileId=%7BImage%20processing%7D§ionId=%7Bthinning-filter%7D"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwww.technotype.net%2Ftutorial%2Ftutorial.php%3FfileId%3D%257BImage%2520processing%257D%26sectionId%3D%257Bthinning-filter%257D" alt="" class="http-favicon" /></a><a href="http://www.technotype.net/tutorial/tutorial.php?fileId=%7BImage%20processing%7D§ionId=%7Bthinning-filter%7D">technotype</a><br />
</p>
<div class="section">
<h3>AForge.NETã®ã¤ã³ã¹ãã¼ã«</h3>
<p>Nugetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããAForgeãã§æ¤ç´¢ï¼ãAForge.Imagingããé¸æãã¦ã¤ã³ã¹ãã¼ã«ï¼</p>
</div>
<div class="section">
<h3>ã½ã¼ã¹ã³ã¼ã</h3>
<p>ãããã»ãã¹æ¼ç®ãè¡ã<a href="http://www.aforgenet.com/framework/docs/html/027a2813-1cf8-c91f-3d9c-365f577afd63.htm">HitAndMissクラス</a>ã使ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// using AForge.Imaging.Filters; ãã½ã¼ã¹ã³ã¼ãã«æ¸ãã¦ãã</span>
<span class="synComment">// å
ç»åã®èªã¿è¾¼ã¿</span>
var bmp = <span class="synStatement">new</span> Bitmap(<span class="synSpecial">@</span><span class="synConstant">"moji.png"</span>);
pictureBox1.Image = bmp;
<span class="synComment">// äºå¤åå¦ç</span>
var gray = <span class="synStatement">new</span> Grayscale(<span class="synConstant">0.2125</span>,<span class="synConstant">0.7154</span>,<span class="synConstant">0.0721</span>).Apply(bmp);
var binary = <span class="synStatement">new</span> Threshold().Apply(gray);
pictureBox2.Image = binary;
<span class="synComment">// ç´°ç·åç¨ã®ï¼ã¤ã®ãã£ã«ã¿ãä½æ</span>
var filterSequence = <span class="synStatement">new</span> FiltersSequence();
filterSequence.Add(<span class="synStatement">new</span> HitAndMiss(
<span class="synStatement">new</span> <span class="synType">short</span>[,] { { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> }, { -<span class="synConstant">1</span>, <span class="synConstant">1</span>, -<span class="synConstant">1</span> }, { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span> } },
HitAndMiss.Modes.Thinning));
filterSequence.Add(<span class="synStatement">new</span> HitAndMiss(
<span class="synStatement">new</span> <span class="synType">short</span>[,] { { -<span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> }, { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> }, { -<span class="synConstant">1</span>, <span class="synConstant">1</span>, -<span class="synConstant">1</span> } },
HitAndMiss.Modes.Thinning));
filterSequence.Add(<span class="synStatement">new</span> HitAndMiss(
<span class="synStatement">new</span> <span class="synType">short</span>[,] { { <span class="synConstant">1</span>, -<span class="synConstant">1</span>, <span class="synConstant">0</span> }, { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> }, { <span class="synConstant">1</span>, -<span class="synConstant">1</span>, <span class="synConstant">0</span> } },
HitAndMiss.Modes.Thinning));
filterSequence.Add(<span class="synStatement">new</span> HitAndMiss(
<span class="synStatement">new</span> <span class="synType">short</span>[,] { { -<span class="synConstant">1</span>, <span class="synConstant">1</span>, -<span class="synConstant">1</span> }, { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> }, { -<span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> } },
HitAndMiss.Modes.Thinning));
filterSequence.Add(<span class="synStatement">new</span> HitAndMiss(
<span class="synStatement">new</span> <span class="synType">short</span>[,] { { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span> }, { -<span class="synConstant">1</span>, <span class="synConstant">1</span>, -<span class="synConstant">1</span> }, { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> } },
HitAndMiss.Modes.Thinning));
filterSequence.Add(<span class="synStatement">new</span> HitAndMiss(
<span class="synStatement">new</span> <span class="synType">short</span>[,] { { -<span class="synConstant">1</span>, <span class="synConstant">1</span>, -<span class="synConstant">1</span> }, { <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span> }, { <span class="synConstant">0</span>, <span class="synConstant">0</span>, -<span class="synConstant">1</span> } },
HitAndMiss.Modes.Thinning));
filterSequence.Add(<span class="synStatement">new</span> HitAndMiss(
<span class="synStatement">new</span> <span class="synType">short</span>[,] { { <span class="synConstant">0</span>, -<span class="synConstant">1</span>, <span class="synConstant">1</span> }, { <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span> }, { <span class="synConstant">0</span>, -<span class="synConstant">1</span>, <span class="synConstant">1</span> } },
HitAndMiss.Modes.Thinning));
filterSequence.Add(<span class="synStatement">new</span> HitAndMiss(
<span class="synStatement">new</span> <span class="synType">short</span>[,] { { <span class="synConstant">0</span>, <span class="synConstant">0</span>, -<span class="synConstant">1</span> }, { <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span> }, { -<span class="synConstant">1</span>, <span class="synConstant">1</span>, -<span class="synConstant">1</span> } },
HitAndMiss.Modes.Thinning));
<span class="synComment">// ãã£ã«ã¿å¦çã®ç¹°ãè¿ãåæ°ãæå®</span>
var filter = <span class="synStatement">new</span> FilterIterator(filterSequence, <span class="synConstant">20</span>);
<span class="synComment">// ç´°ç·åå¦çã®å®è¡</span>
var thinned = filter.Apply(binary);
pictureBox3.Image = thinned;
</pre><p>å®è¡çµæï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140915/20140915092901.png" alt="f:id:whoopsidaisies:20140915092901p:plain" title="f:id:whoopsidaisies:20140915092901p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
whoopsidaisies
C#ã§GISãã¼ã¿ï¼shpãã¡ã¤ã«ï¼ãéã DotSpatialã«ããæ¹æ³
hatenablog://entry/12921228815730750295
2014-09-15T01:10:17+09:00
2014-09-15T01:10:17+09:00 DotSpatialã¯.NETåãã®ãªã¼ãã³ã½ã¼ã¹ã®å°çæ
å ±ã·ã¹ãã ã©ã¤ãã©ãªã§ããï¼ããã使ã£ã¦GISã§ç¨ããããshpãã¡ã¤ã«ï¼ã¨ã»ããã®shxãã¡ã¤ã«ã¨dbfãã¡ã¤ã«ï¼ãèªã¿è¾¼ãï¼ DotSpatialã®ã¤ã³ã¹ãã¼ã« Nugetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããDotSpatialãã§æ¤ç´¢ï¼ããããåºã¦ãããï¼ããã§ã¯ãDotSpatial.Controlsãé¸æãã¦ã¤ã³ã¹ãã¼ã«ï¼ Mapã³ã³ããã¼ã«ã®è¿½å GISãã¼ã¿è¡¨ç¤ºç¨ã®ã³ã³ããã¼ã«ãç¨æããã¦ããã®ã§ããã使ã£ã¦ã¿ãï¼ã¾ãï¼ä¸åº¦ããã¸ã§ã¯ãããã«ãããï¼â¦
<p><a href="http://dotspatial.codeplex.com/">DotSpatial</a>ã¯.NETåãã®ãªã¼ãã³ã½ã¼ã¹ã®å°çæ
å ±ã·ã¹ãã ã©ã¤ãã©ãªã§ããï¼ããã使ã£ã¦GISã§ç¨ããããshpãã¡ã¤ã«ï¼ã¨ã»ããã®shxãã¡ã¤ã«ã¨dbfãã¡ã¤ã«ï¼ãèªã¿è¾¼ãï¼</p>
<div class="section">
<h3>DotSpatialã®ã¤ã³ã¹ãã¼ã«</h3>
<p>Nugetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããDotSpatialãã§æ¤ç´¢ï¼ããããåºã¦ãããï¼ããã§ã¯ãDotSpatial.Controlsãé¸æãã¦ã¤ã³ã¹ãã¼ã«ï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140914/20140914212117.png" alt="f:id:whoopsidaisies:20140914212117p:plain" title="f:id:whoopsidaisies:20140914212117p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>Mapã³ã³ããã¼ã«ã®è¿½å </h3>
<p>GISãã¼ã¿è¡¨ç¤ºç¨ã®ã³ã³ããã¼ã«ãç¨æããã¦ããã®ã§ããã使ã£ã¦ã¿ãï¼</p><p>ã¾ãï¼ä¸åº¦ããã¸ã§ã¯ãããã«ãããï¼ããããã¨DotSpatialã®DLLãå®è¡ãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã«ã³ãã¼ãããï¼</p><p>ãã¼ã«ããã¯ã¹ã®é©å½ãªã¨ããã§ã¯ãªãã¯ãã¦ãã¢ã¤ãã ã®é¸æ(I)...ããé¸æï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140914/20140914212749.png" alt="f:id:whoopsidaisies:20140914212749p:plain" title="f:id:whoopsidaisies:20140914212749p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>ã.NET Framework ã³ã³ãã¼ãã³ããã¿ãã®ãåç
§(B)...ããã¿ã³ãæ¼ãã¦ï¼ã(å®è¡ãã¡ã¤ã«ã®ãã¹)\DotSpatial.Controls.dllããé¸æãããOKï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140914/20140914212821.png" alt="f:id:whoopsidaisies:20140914212821p:plain" title="f:id:whoopsidaisies:20140914212821p:plain" class="hatena-fotolife" itemprop="image"></span></p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140914/20140914213930.png" alt="f:id:whoopsidaisies:20140914213930p:plain" title="f:id:whoopsidaisies:20140914213930p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>ããããã¨ãMapãã¨ããã³ã³ããã¼ã«ã追å ããã¦ããã®ã§ãã©ã¼ã ã«è¿½å ããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140914/20140914213818.png" alt="f:id:whoopsidaisies:20140914213818p:plain" title="f:id:whoopsidaisies:20140914213818p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>ã·ã§ã¼ããã¡ã¤ã«ã®èªã¿è¾¼ã¿</h3>
<p>ã·ã§ã¼ããã¡ã¤ã«ã¯ã<a href="http://www.esrij.com/products/data/japan-shp/"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwww.esrij.com%2Fproducts%2Fdata%2Fjapan-shp%2F" alt="" class="http-favicon" /></a><a href="http://www.esrij.com/products/data/japan-shp/">全国市区町村界データ | データ製品 | 製品 | ESRIジャパン株式会社</a>ãã§ESRI Japanãé
å¸ãã¦ããå
¨å½å¸åºçºæçãã¼ã¿ã使ãï¼ãã¦ã³ãã¼ããã¦è§£çããã以ä¸ã®ã³ã¼ãã追å ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>map1.AddLayer(<span class="synSpecial">@</span><span class="synConstant">"D:\Users\whoops\Downloads\japan_ver72\japan_ver72.shp"</span>);
</pre><p>å®è¡ããã¨ä»¥ä¸ã®ããã«å°å³ã表示ãããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140914/20140914214517.png" alt="f:id:whoopsidaisies:20140914214517p:plain" title="f:id:whoopsidaisies:20140914214517p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>å±æ§æ
å ±ã®è¡¨ç¤º Infoã¢ã¼ã</h3>
<p>ä¸ã®ç¶æ
ã ã¨å°å³ã表示ãããã ãã§ä½ãã§ããªãããMapã³ã³ããã¼ã«ã®ã¢ã¼ããå¤ããï¼ä»¥ä¸ã®ããã«ã³ã¼ãã追å ãã¦Infoã¢ã¼ãã«ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>map1.AddLayer(<span class="synSpecial">@</span><span class="synConstant">"D:\Users\whoops\Downloads\japan_ver72\japan_ver72.shp"</span>);
map1.FunctionMode = DotSpatial.Controls.FunctionMode.Info;
</pre><p>ããã§å®è¡ããã¨ä»¥ä¸ã®ããã«ã¯ãªãã¯ããä½ç½®ã®å¸çºæã®æ
å ±ãè¦ããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140914/20140914214930.png" alt="f:id:whoopsidaisies:20140914214930p:plain" title="f:id:whoopsidaisies:20140914214930p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>é åã®é¸æ Selectã¢ã¼ã</h3>
<p>Selectã¢ã¼ãã«ã«ããã¨ãã©ãã°ã§é åæå®ã§ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>map1.FunctionMode = DotSpatial.Controls.FunctionMode.Select;
</pre><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140915/20140915002531.png" alt="f:id:whoopsidaisies:20140915002531p:plain" title="f:id:whoopsidaisies:20140915002531p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>é¸æããã ãã ã¨ä½ã表示ãããªãã®ã§ï¼TextBoxã«é¸æãããé åã®æ
å ±ã表示ãã¦ã¿ãï¼MAPã³ã³ããã¼ã«ã®MouseUpã¤ãã³ãã追å ãã¦ä»¥ä¸ã®ã³ã¼ããæ¸ãè¾¼ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synType">private</span> <span class="synType">void</span> map1_MouseUp(<span class="synType">object</span> sender, MouseEventArgs e)
{
textBox1.Text = <span class="synConstant">""</span>;
<span class="synComment">// MAPã³ã³ããã¼ã«ãä¿æãã¦ããã¬ã¤ã¤ã¼ãã¼ã¿ãåå¾</span>
var featureLayer = map1.Layers[<span class="synConstant">0</span>] <span class="synStatement">as</span> DotSpatial.Symbology.FeatureLayer;
<span class="synComment">// ãã¹ã¦ã®ãã¼ã¿ã«ã¤ãã¦ã«ã¼ã</span>
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < featureLayer.DrawnStates.Length; ++i)
{
<span class="synComment">// é¸æããã¦ãããã©ããå¤å¥</span>
<span class="synStatement">if</span> (featureLayer.DrawnStates[i].Selected == <span class="synConstant">true</span>)
{
<span class="synComment">// içªç®ã®å±æ§æ
å ±åå¾</span>
var feature = featureLayer.FeatureSet.GetFeature(i);
<span class="synComment">// DataRowãããã£ã¼ã«ãåã§ã¢ã¯ã»ã¹</span>
textBox1.Text += System.String.Format(
<span class="synConstant">"{0} : {1} {2} {3}人"</span>,
feature.DataRow[<span class="synConstant">"JCODE"</span>],
feature.DataRow[<span class="synConstant">"KEN"</span>],
feature.DataRow[<span class="synConstant">"SIKUCHOSON"</span>],
feature.DataRow[<span class="synConstant">"P_NUM"</span>]
)
+ System.Environment.NewLine;
}
}
}
</pre><p>é¸æããã¦ãããã©ããã¯ã¬ã¤ã¤ã¼ãã¼ã¿ã®<a href="http://www.nudoq.org/#!/Packages/DotSpatial.Symbology/DotSpatial.Symbology/LabelLayer/P/DrawnStates">DrawnStates</a>ããããã£ã«æ ¼ç´ããã¦ããï¼</p><p>å±æ§æ
å ±ã¯<a href="https://dotspatial.codeplex.com/wikipage?title=DotSpatial.Data.Vectors.Beginner.FeatureSet">FeatureSet</a>ããããã£ã«æ ¼ç´ããã¦ãã¦<a href="http://www.nudoq.org/#!/Packages/DotSpatial.Data/DotSpatial.Data/PolygonShapefile/M/GetFeature">GetFeature</a>ã¡ã½ããã§æå®ããçªå·ã®ãã¼ã¿ãåå¾ã§ããï¼</p><p>åå±æ§æ
å ±ã¸ã¯ï¼DataRawã«ãã£ã¼ã«ãåãæå®ãããã¨ã§åå¾ã§ããï¼ãã®ãµã³ãã«ã§ä½¿ã£ã¦ãããã£ã¼ã«ãåã¯ã<a href="http://www.esrij.com/products/data/japan-shp/">全国市区町村界データ | データ製品 | 製品 | ESRIジャパン株式会社</a>ããåç
§ï¼</p><p>å®è¡ãã¦ãã©ãã°ã§é åé¸æããã¨ä»¥ä¸ã®ããã«TextBoxã«æ
å ±ã表示ãããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140915/20140915004858.png" alt="f:id:whoopsidaisies:20140915004858p:plain" title="f:id:whoopsidaisies:20140915004858p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>MAPã³ã³ããã¼ã«ãªãã§èªã¿è¾¼ã¿</h3>
<p>MAPã³ã³ããã¼ã«ãé
ç½®ããªãã¦ã<a href="http://www.nudoq.org/#!/Packages/DotSpatial.Data/DotSpatial.Data/DataManager">DataManager</a>ã¯ã©ã¹ã®<a href="http://www.nudoq.org/#!/Packages/DotSpatial.Data/DotSpatial.Data/DataManager/M/OpenFile">OpenFile</a>ã¡ã½ããã使ãã°ã·ã§ã¼ããã¡ã¤ã«ã¯èªã¿è¾¼ããï¼</p><p>以ä¸ã«ã·ã§ã¼ããã¡ã¤ã«ãèªã¿è¾¼ãã§ï¼0çªç®ã®ãã¼ã¿ã®åº§æ¨ãåºåããã³ã¼ããè¼ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// ã·ã§ã¼ããã¡ã¤ã«ã®èªã¿è¾¼ã¿</span>
var layer = DotSpatial.Data.DataManager.DefaultDataManager.OpenFile(<span class="synSpecial">@</span><span class="synConstant">"D:\Users\whoops\Downloads\japan_ver72\japan_ver72.shp"</span>)
<span class="synStatement">as</span> DotSpatial.Data.FeatureSet;
<span class="synComment">// 0çªç®ã®ãã¼ã¿ã®åº§æ¨ã表示</span>
<span class="synStatement">foreach</span> (var cordinate <span class="synStatement">in</span> layer.GetFeature(<span class="synConstant">0</span>).Coordinates)
{
Console.WriteLine(cordinate.ToString());
}
</pre><p>å®è¡çµæ<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140915/20140915010455.png" alt="f:id:whoopsidaisies:20140915010455p:plain" title="f:id:whoopsidaisies:20140915010455p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>ã³ã³ããã¼ã«ã使ããªãæ¹æ³ã ãã使ãå ´åNuGetã§ãDotSpatial.Dataããã¤ã³ã¹ãã¼ã«ããã°ã§ããï¼</p>
</div>
whoopsidaisies
SVGã¢ãã¡ã¼ã·ã§ã³ã§åé³ãã¯ã®ä¸çæ¸ã
hatenablog://entry/12921228815732826994
2014-09-13T22:22:26+09:00
2014-09-13T22:22:26+09:00 SVGã«ããã¢ãã¡ã¼ã·ã§ã³ã®åå¼·ã¡ã¢ã¨ï¼ä½ã£ãåé³ãã¯ã®ä¸çæ¸ãã¢ãã¡ã¼ã·ã§ã³ï¼ã¢ãã¡ã¼ã·ã§ã³ãSVGã®animateMotionè¦ç´ ã¨ï¼CSSã®animationããããã£ã使ã£ãï¼æ¬å½ã¯CSS使ããªãã§ããããã£ãã®ã ãã©ããã ã¨é¢åããããã ã£ãã®ã§CSSã使ã£ãï¼å
ç»åã¯ä»¥ä¸ã®ãµã¤ãããæã£ã¦ããï¼ piapro(ãã¢ãã)|ã¤ã©ã¹ããä¸çæ¸ã㧠åé³ãã¯ã æãã¾ããã 以ä¸ãä½ã£ãã¢ãã¡ã¼ã·ã§ã³ï¼SVGã¨CSSã®ã¢ãã¡ã¼ã·ã§ã³ã®åæã®åãæ¹ãããããªãã£ãã®ã§ï¼èªã¿è¾¼ã¿ã®åº¦ã«ã¿ã¤ãã³ã°ãå¤ãã£ã¦ãã¾ãï¼ â»SVGãã¡ã¤ã«ãç½®ãã®ã«åãã¦ããã¬ã³ã¿ã«ãµã¼ãã¼ã®æéãåãã¦ãã¾ã£ãããâ¦
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a>ã«ããã¢ãã¡ã¼ã·ã§ã³ã®åå¼·ã¡ã¢ã¨ï¼ä½ã£ã<a class="keyword" href="http://d.hatena.ne.jp/keyword/%BD%E9%B2%BB%A5%DF%A5%AF">åé³ãã¯</a>ã®ä¸çæ¸ãã¢ãã¡ã¼ã·ã§ã³ï¼</p><p>ã¢ãã¡ã¼ã·ã§ã³ã<a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a>ã®animateMotionè¦ç´ ã¨ï¼<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>ã®animationããããã£ã使ã£ãï¼æ¬å½ã¯<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>使ããªãã§ããããã£ãã®ã ãã©ããã ã¨é¢åããããã ã£ãã®ã§<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>ã使ã£ãï¼</p><p>å
ç»åã¯ä»¥ä¸ã®ãµã¤ãããæã£ã¦ããï¼<br />
<a href="http://piapro.jp/t/zL1d"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fpiapro.jp%2Ft%2FzL1d" alt="" class="http-favicon" /></a><a href="http://piapro.jp/t/zL1d">piapro(ピアプロ)|イラスト「一筆書きで 初音ミクを 描きました」</a></p><p><del><br />
以ä¸ãä½ã£ãã¢ãã¡ã¼ã·ã§ã³ï¼<a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a>ã¨<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>ã®ã¢ãã¡ã¼ã·ã§ã³ã®åæã®åãæ¹ãããããªãã£ãã®ã§ï¼èªã¿è¾¼ã¿ã®åº¦ã«ã¿ã¤ãã³ã°ãå¤ãã£ã¦ãã¾ãï¼</del><br />
â»<a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a>ãã¡ã¤ã«ãç½®ãã®ã«åãã¦ãã<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%EC%A5%F3%A5%BF%A5%EB%A5%B5%A1%BC%A5%D0%A1%BC">ã¬ã³ã¿ã«ãµã¼ãã¼</a>ã®æéãåãã¦ãã¾ã£ããããæãªã¨ãå¥ã®ã¨ããã«ã¢ãããã¼ãããªããã¾ãã</p>
<div class="section">
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a> animateMotionè¦ç´ </h3>
<p>赤ãåã移åãããã®ã«ã¯ï¼<a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a>ã®<a href="https://developer.mozilla.org/ja/docs/Web/SVG/Element/animateMotion">animateMotion要素</a>ã使ã£ãï¼</p><p>animateMotionè¦ç´ ãç¨ããã¨ï¼å³å½¢ãpathã§æå®ããä»»æã®æ²ç·ã«æ²¿ã£ã¦ç§»åããããã¨ãåºæ¥ãï¼ã¾ãï¼<a href="https://developer.mozilla.org/ja/docs/Web/SVG/Element/mpath">mpath要素</a>ã«ãã£ã¦ä»¥ä¸ã®ããã«pathã®åç
§ãå¯è½ï¼</p>
<blockquote cite="https://developer.mozilla.org/ja/docs/Web/SVG/Element/animateMotion">
<pre class="code lang-xml" data-lang="xml" data-unlink><span class="synIdentifier"><path </span><span class="synType">d</span>=<span class="synConstant">"M10,110 A120,120 -45 0,1 110 10 A120,120 -45 0,1 10,110"</span>
<span class="synIdentifier"> </span><span class="synType">stroke</span>=<span class="synConstant">"lightgrey"</span><span class="synIdentifier"> </span><span class="synType">stroke-width</span>=<span class="synConstant">"2"</span><span class="synIdentifier"> </span>
<span class="synIdentifier"> </span><span class="synType">fill</span>=<span class="synConstant">"none"</span><span class="synIdentifier"> </span><span class="synType">id</span>=<span class="synConstant">"theMotionPath"</span><span class="synIdentifier">/></span>
<span class="synIdentifier"><circle </span><span class="synType">cx</span>=<span class="synConstant">"10"</span><span class="synIdentifier"> </span><span class="synType">cy</span>=<span class="synConstant">"110"</span><span class="synIdentifier"> </span><span class="synType">r</span>=<span class="synConstant">"3"</span><span class="synIdentifier"> </span><span class="synType">fill</span>=<span class="synConstant">"lightgrey"</span><span class="synIdentifier"> /></span>
<span class="synIdentifier"><circle </span><span class="synType">cx</span>=<span class="synConstant">"110"</span><span class="synIdentifier"> </span><span class="synType">cy</span>=<span class="synConstant">"10"</span><span class="synIdentifier"> </span><span class="synType">r</span>=<span class="synConstant">"3"</span><span class="synIdentifier"> </span><span class="synType">fill</span>=<span class="synConstant">"lightgrey"</span><span class="synIdentifier"> /></span>
<span class="synComment"><!-- Here is a red circle which will be moved along the motion path. --></span>
<span class="synIdentifier"><circle </span><span class="synType">cx</span>=<span class="synConstant">""</span><span class="synIdentifier"> </span><span class="synType">cy</span>=<span class="synConstant">""</span><span class="synIdentifier"> </span><span class="synType">r</span>=<span class="synConstant">"5"</span><span class="synIdentifier"> </span><span class="synType">fill</span>=<span class="synConstant">"red"</span><span class="synIdentifier">></span>
<span class="synComment"><!-- Define the motion path animation --></span>
<span class="synIdentifier"><animateMotion </span><span class="synType">dur</span>=<span class="synConstant">"6s"</span><span class="synIdentifier"> </span><span class="synType">repeatCount</span>=<span class="synConstant">"indefinite"</span><span class="synIdentifier">></span>
<span class="synIdentifier"><mpath </span><span class="synType">xlink</span><span class="synComment">:</span><span class="synType">href</span>=<span class="synConstant">"#theMotionPath"</span><span class="synIdentifier">/></span>
<span class="synIdentifier"></animateMotion></span>
<span class="synIdentifier"></circle></span>
</pre>
<cite><a href="https://developer.mozilla.org/ja/docs/Web/SVG/Element/animateMotion">animateMotion - SVG | MDN</a></cite>
</blockquote>
</div>
<div class="section">
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a> animateè¦ç´ </h3>
<p>ç·ãæãã¦ããæ§åã¯ï¼<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>ã®<a href="http://css-tricks.com/svg-line-animation-works/">animate要素を使って破線の間隔を変える方法</a>ã使ã£ãï¼<br />
ç ´ç·ã®ééãå¤ãããã¨ã§ç·ã伸ã³ã¦è¡ã£ã¦ããããã«è¦ããããã ï¼</p>
<blockquote cite="http://css-tricks.com/svg-line-animation-works/">
<p><img src="http://cdn.css-tricks.com/wp-content/uploads/2014/02/animate-stroke-full.gif"></img></p>
<cite><a href="http://css-tricks.com/svg-line-animation-works/">How SVG Line Animation Works | CSS-Tricks</a></cite>
</blockquote>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>ã«ä»¥ä¸ã®ããã«æãã¦ããã¨ããããã ãï¼stroke-dasharrayãstroke-dashoffsetã®å¤ãç·ã®é·ããããã«ããªãã¦ã¯ãªããªããããå°ãé¢åï¼</p>
<pre class="code lang-css" data-lang="css" data-unlink>path <span class="synIdentifier">{</span>
stroke-dasharray: <span class="synConstant">1000</span>;
stroke-dashoffset: <span class="synConstant">1000</span>;
animation: dash <span class="synConstant">5s</span> linear forwards;
<span class="synIdentifier">}</span>
@keyframes dash <span class="synIdentifier">{</span>
to {
stroke-dashoffset: <span class="synConstant">0</span>;
<span class="synIdentifier">}</span>
<span class="synError">}</span>
</pre>
</div>
<div class="section">
<h3>d3.jsã§ä½æ</h3>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%BD%E9%B2%BB%A5%DF%A5%AF">åé³ãã¯</a>ã®åº§æ¨ãã¼ã¿ã¯ç»åãããã¤ãã¤ã¨æ½åºããï¼ä»¥ä¸ãããã¦ã³ãã¼ãå¯è½ï¼<br />
<a href="http://whoopsidaisies.site-station.net/blog/miku.csv">http://whoopsidaisies.site-station.net/blog/miku.csv</a></p><p><a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a>ç´æã¡ã§ãããã£ããï¼ãã£ãããªã®ã§d3.jsã§<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSV">CSV</a>ãã¡ã¤ã«ãèªã¿è¾¼ãã§<a class="keyword" href="http://d.hatena.ne.jp/keyword/SVG">SVG</a>ãåãåºããï¼</p>
<pre class="code lang-javascript" data-lang="javascript" data-unlink>d3.csv(<span class="synConstant">"miku2.csv"</span>, <span class="synIdentifier">function</span> (data) <span class="synIdentifier">{</span>
<span class="synIdentifier">var</span> line = d3.svg.line()
.x(<span class="synIdentifier">function</span> (d) <span class="synIdentifier">{</span> <span class="synStatement">return</span> Math.round(d.x * 10) / 10; <span class="synIdentifier">}</span>)
.y(<span class="synIdentifier">function</span> (d) <span class="synIdentifier">{</span> <span class="synStatement">return</span> Math.round(d.y * 10) / 10; <span class="synIdentifier">}</span>)
.interpolate(<span class="synConstant">"linear"</span>);
<span class="synIdentifier">var</span> svg = d3.select(<span class="synConstant">"body"</span>).append(<span class="synConstant">"svg"</span>).attr(<span class="synConstant">"width"</span>, 700).attr(<span class="synConstant">"height"</span>, 900);
<span class="synIdentifier">var</span> path = svg.append(<span class="synConstant">"path"</span>)
.attr(<span class="synIdentifier">{</span>
<span class="synConstant">"d"</span>: line(data),
<span class="synConstant">"stroke"</span>: <span class="synConstant">"black"</span>,
<span class="synConstant">"stroke-width"</span>: 2,
<span class="synConstant">"fill"</span>: <span class="synConstant">"none"</span>,
<span class="synConstant">"id"</span>: <span class="synConstant">"mikupath"</span>
<span class="synIdentifier">}</span>);
svg.append(<span class="synConstant">"circle"</span>)
.attr(<span class="synIdentifier">{</span>
<span class="synConstant">"cx"</span>: <span class="synConstant">""</span>,
<span class="synConstant">"cy"</span>: <span class="synConstant">""</span>,
<span class="synConstant">"r"</span>: <span class="synConstant">"5"</span>,
<span class="synConstant">"fill"</span>: <span class="synConstant">"red"</span>
<span class="synIdentifier">}</span>)
.append(<span class="synConstant">"animateMotion"</span>)
.attr(<span class="synIdentifier">{</span>
<span class="synConstant">"dur"</span>: <span class="synConstant">"20s"</span>,
<span class="synConstant">"repeatCount"</span>: <span class="synConstant">"indefinite"</span>
<span class="synIdentifier">}</span>)
.append(<span class="synConstant">"mpath"</span>)
.attr(<span class="synConstant">"xlink:href"</span>, <span class="synConstant">"#mikupath"</span>);
<span class="synIdentifier">}</span>);
</pre><p><del><br />
<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%BD%A1%BC%A5%B9%A5%B3%A1%BC%A5%C9">ã½ã¼ã¹ã³ã¼ã</a>å
¨æã¯ä»¥ä¸ï¼<br />
<a href="http://whoopsidaisies.site-station.net/blog/mikuanimation2.html">http://whoopsidaisies.site-station.net/blog/mikuanimation2.html</a><br />
</del><br />
<del><br />
å®è¡å¾ã®htmlã¯ä»¥ä¸ï¼<br />
<a href="http://whoopsidaisies.site-station.net/blog/mikuanimation.html">http://whoopsidaisies.site-station.net/blog/mikuanimation.html</a><br />
</del><br />
â»<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%EC%A5%F3%A5%BF%A5%EB%A5%B5%A1%BC%A5%D0%A1%BC">ã¬ã³ã¿ã«ãµã¼ãã¼</a>ã®æéãåãã¦ãã¾ã£ããããæãªã¨ãå¥ã®ã¨ããã«ã¢ãããã¼ãããªããã¾ãã</p>
</div>
whoopsidaisies
PowerPointã®ãªã¼ãã·ã§ã¤ãã§å¥½ããªé¢æ°ã®æ²ç·ãä½ããC# NetOfficeã«ããæ¹æ³
hatenablog://entry/12921228815732529471
2014-09-11T12:43:18+09:00
2014-09-11T12:43:18+09:00 sin(x)/xã®ãªã¼ãã·ã§ã¤ããªã¼ãã·ã§ã¤ãã§ããããªæ³¢å½¢ãä½ãããã¨ãããã¾ã«ããã®ã ãã©ï¼C#ã使ã£ã¦ä¸ã®ç»åã¿ããã«sin(x)/xã®ãªã¼ãã·ã§ã¤ããããã¨ãããã«ä½ããã®ã§æé ãã¾ã¨ããï¼è©¦ããç°å¢ã¯PowerPoint2010ã¨Visual Studio 2013ï¼ãã¼ã¸ã§ã³ãéãã¨å°ãå¤ããå¯è½æ§ã¯ããã¨æãï¼ï¼ããããC#ã§ãããã¨ãVBAãã¯ãã§ãåããã¨ã¯åºæ¥ããã©ï¼VBAã¯è¦æãªã®ã§C#ã§ããï¼VBAã§ã®ããæ¹ãå¾è¿°ãã¾ãï¼åºæ¥ä¸ãã£ãPowerPointãã¡ã¤ã«ã以ä¸ãããã¦ã³ãã¼ãã§ããããã«ãã¦ãããï¼ sinc.pptx - Google ãã©ã¤ã NetOffiâ¦
<p><figure><br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140911/20140911101713.png" alt="f:id:whoopsidaisies:20140911101713p:plain" title="f:id:whoopsidaisies:20140911101713p:plain" class="hatena-fotolife" itemprop="image"></span><br />
<figcaption align="center">sin(x)/xã®ãªã¼ãã·ã§ã¤ã</figcaption></figure></p><p>ãªã¼ãã·ã§ã¤ãã§ããããªæ³¢å½¢ãä½ãããã¨ãããã¾ã«ããã®ã ãã©ï¼C#ã使ã£ã¦ä¸ã®ç»åã¿ããã«sin(x)/xã®ãªã¼ãã·ã§ã¤ããããã¨ãããã«ä½ããã®ã§æé ãã¾ã¨ããï¼</p><p>試ããç°å¢ã¯PowerPoint2010ã¨Visual Studio 2013ï¼ãã¼ã¸ã§ã³ãéãã¨å°ãå¤ããå¯è½æ§ã¯ããã¨æãï¼ï¼ããããC#ã§ãããã¨ãVBAãã¯ãã§ãåããã¨ã¯åºæ¥ããã©ï¼VBAã¯è¦æãªã®ã§C#ã§ããï¼VBAã§ã®ããæ¹ãå¾è¿°ãã¾ãï¼</p><p>åºæ¥ä¸ãã£ãPowerPointãã¡ã¤ã«ã以ä¸ãããã¦ã³ãã¼ãã§ããããã«ãã¦ãããï¼<br />
<a href="https://docs.google.com/file/d/0B8I67X8vyAXOSFJLaTlIOGhsMGM/edit"><img src="http://cdn-ak.favicon.st-hatena.com/?url=https%3A%2F%2Fdocs.google.com%2Ffile%2Fd%2F0B8I67X8vyAXOSFJLaTlIOGhsMGM%2Fedit" alt="" class="http-favicon" /></a><a href="https://docs.google.com/file/d/0B8I67X8vyAXOSFJLaTlIOGhsMGM/edit">sinc.pptx - Google ドライブ</a><br />
</p>
<div class="section">
<h3>NetOffice.PowerPointã®ã¤ã³ã¹ãã¼ã«</h3>
<p>以åã<a href="http://whoopsidaisies.hatenablog.com/entry/2014/06/19/101032">C#でExcelファイルを作成・グラフを挿入する NetOfficeによる方法 - whoopsidaisies's diary</a>ãã§ç´¹ä»ããï¼<a href="http://netoffice.codeplex.com/">NetOffice</a>ã¨ãã.NETç¨ã®ã©ã¤ãã©ãªã使ãã¨PowerPointçã«ã¢ã¯ã»ã¹ãã¦è²ã
åºæ¥ãã®ã§ãããå©ç¨ããï¼</p><p>NetOfficeã¯NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããNetOffice.PowerPointããæ¤ç´¢ãã¦ã¤ã³ã¹ãã¼ã«ï¼</p>
</div>
<div class="section">
<h3>ã½ã¼ã¹ã³ã¼ã</h3>
<p>以ä¸ã«ã½ã¼ã¹ã³ã¼ããè¼ããï¼ã¹ã©ã¤ããä½ã£ã¦<a href="http://msdn.microsoft.com/ja-jp/library/office/ff744765(v=office.15).aspx">AddCurve</a>ã¡ã½ããã§æ²ç·ã追å ãã¦ããã ãã§ããï¼</p><p>AddCurveã¡ã½ããã®å¼æ°ã¨ãã¦ï¼float[(ç¹ã®æ°),2]ã«åº§æ¨ãæ ¼ç´ãã¦æ¸¡ãï¼ãã®ç¹ã®åº§æ¨ãå
ã«ãã¸ã§æ²ç·ãæãããã§ããï¼<a href="http://msdn.microsoft.com/ja-jp/library/office/ff744765(v=office.15).aspx">点の数は3n+1個</a>ã«ããªãã¨æ¢ã¾ãã®ã§æ³¨æï¼</p><p>ç¹ã®åº§æ¨ã¯ã¹ã©ã¤ãã®å·¦ä¸ã(0,0)ã§ãã¯ã»ã«ã§æå®ããï¼ã¹ã©ã¤ãã®ãªãã¸ã§ã¯ãã®<a href="http://msdn.microsoft.com/ja-jp/library/office/ff745135(v=office.15).aspx">PageSetup</a>ããããã£ã«ã¹ã©ã¤ãã®å¹
ã¨é«ããæ ¼ç´ããã¦ããã®ã§ãããå
ã«å¤§ããã調æ´ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synType">static</span> <span class="synType">void</span> Main(<span class="synType">string</span>[] args)
{
<span class="synComment">// ãã¯ã¼ãã¤ã³ããéã</span>
<span class="synStatement">using</span> (var app = <span class="synStatement">new</span> NetOffice.PowerPointApi.Application())
{
<span class="synComment">// ãã¬ã¼ã³ãã¼ã·ã§ã³ã®ä½æ</span>
var presentation = app.Presentations.Add();
<span class="synComment">// ã¹ã©ã¤ãã®è¿½å </span>
var slide = presentation.Slides.Add(<span class="synConstant">1</span>, NetOffice.PowerPointApi.Enums.PpSlideLayout.ppLayoutBlank);
<span class="synComment">// sin(x)/xã®åº§æ¨ãå¾ã</span>
var sinc = GetSinc(presentation.PageSetup.SlideWidth, presentation.PageSetup.SlideHeight);
<span class="synComment">// 座æ¨ãããã¸ã§æ²ç·ãæç»ãã</span>
<span class="synComment">// å¼æ°ã¯floatã®äºæ¬¡å
é
åï¼åº§æ¨ã®æ°ã¯6n+1åãããªãã¨ãããªããã注æï¼</span>
slide.Shapes.AddCurve(sinc);
<span class="synComment">// ãã¬ã¼ã³ãã¼ã·ã§ã³ã®ä¿å</span>
presentation.SaveAs(<span class="synSpecial">@</span><span class="synConstant">"D:\a.pptx"</span>);
<span class="synComment">// ãã¬ã¼ã³ãã¼ã·ã§ã³ãã¡ã¤ã«ãéãã</span>
presentation.Close();
<span class="synComment">// ãã¯ã¼ãã¤ã³ãã®çµäºãä½æãããã¡ã¤ã«ä»¥å¤ãéããããã®ã§æ³¨æ</span>
<span class="synComment">//app.Quit();</span>
}
}
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">summary</span><span class="synIdentifier">></span>
<span class="synComment">/// sin(x)/xé¢æ°ã®åº§æ¨ãã¹ã©ã¤ãã®å¤§ããã«åããã¦æ¡å¤§ï¼</span>
<span class="synComment">/// </span><span class="synIdentifier"></</span><span class="synStatement">summary</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">param</span><span class="synIdentifier"> </span><span class="synType">name</span>=<span class="synConstant">"slideWidth"</span><span class="synIdentifier">></span><span class="synComment">ã¹ã©ã¤ãã®å¹
</span><span class="synIdentifier"></</span><span class="synStatement">param</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">param</span><span class="synIdentifier"> </span><span class="synType">name</span>=<span class="synConstant">"slideHeight"</span><span class="synIdentifier">></span><span class="synComment">ã¹ã©ã¤ãã®é«ã</span><span class="synIdentifier"></</span><span class="synStatement">param</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">returns</span><span class="synIdentifier">></span><span class="synComment">sin(x)/xé¢æ°ãæãããã®ç¹ã®åº§æ¨</span><span class="synIdentifier"></</span><span class="synStatement">returns</span><span class="synIdentifier">></span>
<span class="synType">static</span> <span class="synType">float</span>[,] GetSinc(<span class="synType">float</span> slideWidth, <span class="synType">float</span> slideHeight)
{
<span class="synComment">// xã-4Ïï½4Ïã¾ã§ã®sin(x)/xãæ±ããï¼601ç¹ï¼</span>
var xs = Enumerable.Range(-<span class="synConstant">300</span>, <span class="synConstant">601</span>).Select(x => x * <span class="synConstant">4</span> * Math.PI / <span class="synConstant">300</span>);
var ys = xs.Select(x => x != <span class="synConstant">0</span> ? Math.Sin(x) / x : <span class="synConstant">1</span>);
<span class="synComment">// PowerPointã®ã¹ã©ã¤ãã®ãµã¤ãºã«åããã¦ç§»åã»æ¡å¤§ããã</span>
<span class="synComment">// ä¸å¿åº§æ¨</span>
var cx = slideWidth / <span class="synConstant">2</span>;
var cy = slideHeight / <span class="synConstant">2</span>;
<span class="synComment">// ãªãã¸ã§ã¯ãã®ã ãããã®å¤§ãã</span>
var width = slideWidth * <span class="synConstant">0.8</span>;
var height = slideHeight * <span class="synConstant">0.8</span>;
var pptXs = xs.Select(x => x / (<span class="synConstant">4</span> * Math.PI) * width / <span class="synConstant">2</span> + cx).ToArray();
var pptYs = ys.Select(y => -y * height / <span class="synConstant">2</span> + cy).ToArray();
<span class="synComment">// AddCurveã¡ã½ããã«æ¸¡ãããã«floatã®2次å
é
åã«ä»£å
¥ãã</span>
var sinc = <span class="synStatement">new</span> <span class="synType">float</span>[pptXs.Length, <span class="synConstant">2</span>];
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < pptXs.Length; ++ i)
{
sinc[i, <span class="synConstant">0</span>] = (<span class="synType">float</span>)pptXs[i];
sinc[i, <span class="synConstant">1</span>] = (<span class="synType">float</span>)pptYs[i];
}
<span class="synStatement">return</span> sinc;
}
</pre><p>å®è¡ããã¨ï¼è¨äºã®æåã®ç»åã®pptxãã¡ã¤ã«ãä½æãããï¼GetSincã¡ã½ããã®é¨åãé©å½ãªåº§æ¨ãæ ¼ç´ãããããã«å¤ããã°èªåã®å¥½ããªæ²ç·ãå¼ããï¼</p><p>ã¡ãªã¿ã«åºæ¥ãæ²ç·ã¯ãªã¼ãã·ã§ã¤ããªã®ã§ï¼ä»¥ä¸ã®ç»åã®ããã«ç·ã®å¤ªãã¨ã種é¡ã¨ãè²ã¨ããç°¡åã«å¤ããããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140911/20140911115617.png" alt="f:id:whoopsidaisies:20140911115617p:plain" title="f:id:whoopsidaisies:20140911115617p:plain" class="hatena-fotolife" itemprop="image"></span><br />
æ¡å¤§ãã¦ããããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140911/20140911115623.png" alt="f:id:whoopsidaisies:20140911115623p:plain" title="f:id:whoopsidaisies:20140911115623p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>VBAãã¯ãã§ã®ããæ¹</h3>
<p>è¨äºã®æåã«ãè¿°ã¹ããï¼C#ã使ããã¨ãVBAãã¯ãã§åããã¨ãåºæ¥ãï¼ä»¥ä¸ã«åèã«ãªãã³ã¼ããè¼ããï¼<a href="http://msdn.microsoft.com/ja-jp/library/office/ff744765(v=office.15).aspx">ここ</a>ã®ãµã³ãã«è¦ãããããã ãã ãã©ï¼ï¼</p><p>ããã®ç¹ã®åº§æ¨ãå¼ãããæ²ç·ã®åº§æ¨ã«ãã¦ããã°OK.</p>
<pre class="code lang-vb" data-lang="vb" data-unlink><span class="synStatement">Sub</span> DrawCurve<span class="synStatement">()</span>
<span class="synComment"> ' 1æç®ã®ã¹ã©ã¤ãã®ãªãã¸ã§ã¯ããå¾ã</span>
<span class="synStatement">Dim</span> slide <span class="synStatement">As</span> PowerPoint<span class="synStatement">.</span>slide
<span class="synStatement">Set</span> slide <span class="synStatement">=</span> ActivePresentation<span class="synStatement">.</span>Slides<span class="synStatement">(</span><span class="synConstant">1</span><span class="synStatement">)</span>
<span class="synComment"> ' ãã¸ã§æ²ç·ãå¼ãããã®ç¹ã®åº§æ¨ãé
åã«æ ¼ç´</span>
<span class="synComment"> ' ããã®åº§æ¨ã®å¤ãé©å½ã«å¤ãã¦ããã°å¥½ããªæ²ç·ãå¼ãã</span>
<span class="synStatement">Dim</span> points<span class="synStatement">(</span><span class="synConstant">1</span> <span class="synStatement">To</span> <span class="synConstant">7</span><span class="synStatement">,</span> <span class="synConstant">1</span> <span class="synStatement">To</span> <span class="synConstant">2</span><span class="synStatement">)</span> <span class="synStatement">As</span> <span class="synType">Single</span>
points<span class="synStatement">(</span><span class="synConstant">1</span><span class="synStatement">,</span> <span class="synConstant">1</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">0</span>
points<span class="synStatement">(</span><span class="synConstant">1</span><span class="synStatement">,</span> <span class="synConstant">2</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">0</span>
points<span class="synStatement">(</span><span class="synConstant">2</span><span class="synStatement">,</span> <span class="synConstant">1</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">72</span>
points<span class="synStatement">(</span><span class="synConstant">2</span><span class="synStatement">,</span> <span class="synConstant">2</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">72</span>
points<span class="synStatement">(</span><span class="synConstant">3</span><span class="synStatement">,</span> <span class="synConstant">1</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">100</span>
points<span class="synStatement">(</span><span class="synConstant">3</span><span class="synStatement">,</span> <span class="synConstant">2</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">40</span>
points<span class="synStatement">(</span><span class="synConstant">4</span><span class="synStatement">,</span> <span class="synConstant">1</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">20</span>
points<span class="synStatement">(</span><span class="synConstant">4</span><span class="synStatement">,</span> <span class="synConstant">2</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">50</span>
points<span class="synStatement">(</span><span class="synConstant">5</span><span class="synStatement">,</span> <span class="synConstant">1</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">90</span>
points<span class="synStatement">(</span><span class="synConstant">5</span><span class="synStatement">,</span> <span class="synConstant">2</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">120</span>
points<span class="synStatement">(</span><span class="synConstant">6</span><span class="synStatement">,</span> <span class="synConstant">1</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">60</span>
points<span class="synStatement">(</span><span class="synConstant">6</span><span class="synStatement">,</span> <span class="synConstant">2</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">30</span>
points<span class="synStatement">(</span><span class="synConstant">7</span><span class="synStatement">,</span> <span class="synConstant">1</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">150</span>
points<span class="synStatement">(</span><span class="synConstant">7</span><span class="synStatement">,</span> <span class="synConstant">2</span><span class="synStatement">)</span> <span class="synStatement">=</span> <span class="synConstant">90</span>
<span class="synComment"> ' æ²ç·ã®è¿½å </span>
slide<span class="synStatement">.</span>Shapes<span class="synStatement">.</span>AddCurve SafeArrayOfPoints:<span class="synStatement">=</span>points
<span class="synStatement">End</span> <span class="synStatement">Sub</span>
</pre>
</div>
whoopsidaisies
OpenCVã§DeepFlow
hatenablog://entry/12921228815730868159
2014-08-21T22:16:42+09:00
2014-08-21T22:16:42+09:00 opencv_contribãè¦ã¦ããï¼DeepFlowã¨ãããªããã£ã«ã«ããã¼ã®ã¢ã«ã´ãªãºã ãå®è£
ããã¦ããã®ã§åå¼·ã¤ãã§ã«ä½¿ã£ã¦ã¿ãï¼ DeepFlow DeepFlowã¯ã³ã³ãã¥ã¼ã¿ãã¸ã§ã³ã®åéã§ã¯æåãªå½éå¦ä¼ICCV2013ã§Weinzaepfelãã«ãã£ã¦çºè¡¨ãããã¢ã«ã´ãªãºã ã§ããï¼ HAL - INRIA :: [hal-00873592, version 1] DeepFlow: Large displacement optical flow with deep matchingDeepFlowã§ã¯Deep Matchingã¨ããç»åã®ãããã³ã°ææ³ï¼ãããåè«æå
ã§ææ¡ãâ¦
<p><a href="http://code.opencv.org/projects/opencv/wiki/ChangeLog">opencv_contrib</a>ãè¦ã¦ããï¼<a href="http://lear.inrialpes.fr/src/deepmatching/">DeepFlow</a>ã¨ãããªããã£ã«ã«ããã¼ã®ã¢ã«ã´ãªãºã ãå®è£
ããã¦ããã®ã§åå¼·ã¤ãã§ã«ä½¿ã£ã¦ã¿ãï¼</p>
<div class="section">
<h3>DeepFlow</h3>
<p>DeepFlowã¯ã³ã³ãã¥ã¼ã¿ãã¸ã§ã³ã®åéã§ã¯æåãªå½éå¦ä¼<a href="http://www.iccv2013.org/">ICCV2013</a>ã§Weinzaepfelãã«ãã£ã¦çºè¡¨ãããã¢ã«ã´ãªãºã ã§ããï¼<br />
<a href="http://hal.inria.fr/hal-00873592"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fhal.inria.fr%2Fhal-00873592" alt="" class="http-favicon" /></a><a href="http://hal.inria.fr/hal-00873592">HAL - INRIA :: [hal-00873592, version 1] DeepFlow: Large displacement optical flow with deep matching</a></p><p>DeepFlowã§ã¯Deep Matchingã¨ããç»åã®ãããã³ã°ææ³ï¼ãããåè«æå
ã§ææ¡ããã¦ããï¼ãç¨ãã¦ãªããã£ã«ã«ããã¼ãæ±ãã¦ããï¼</p><p>以ä¸ã®ç»åã«ã¢ã«ã´ãªãºã ã®å
¨ä½åãã¾ã¨ãããã¦ããï¼</p>
<blockquote cite="http://lear.inrialpes.fr/src/deepmatching/">
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140821/20140821140023.jpg" alt="f:id:whoopsidaisies:20140821140023j:plain" title="f:id:whoopsidaisies:20140821140023j:plain" class="hatena-fotolife" itemprop="image"></span></p>
<cite><a href="http://lear.inrialpes.fr/src/deepmatching/"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Flear.inrialpes.fr%2Fsrc%2Fdeepmatching%2F" alt="" class="http-favicon" /></a><a href="http://lear.inrialpes.fr/src/deepmatching/">LEAR - DeepMatchingFlow</a></cite>
</blockquote>
<p>ãã¯ã¼ãã¤ã³ãã®è³æã¯<a href="http://lear.inrialpes.fr/people/pweinzae/files/DeepFlow_iccv2013_slides.ppt">こちら</a><br />
</p>
<div class="section">
<h4>Deep Matching</h4>
<p><a href="http://lear.inrialpes.fr/people/revaud/">Deep Matching</a>ã§ã¯ï¼ç³ã¿è¾¼ã¿ï¼ãã¼ãªã³ã°ï¼ãµããµã³ããªã³ã°ãç¹°ãè¿ãããã¨ã§ï¼ç»åéã®Quasi-Denseãªãããã³ã°ï¼æ¥æ¬èªã§ãªãã¦ãããããããªãï¼æºå¯ï¼ï¼ãæ±ããï¼</p><p>Deep Learningã§æ³¨ç®ãéãã¦ããConvolutional Neural Networksï¼CNNï¼ã«ä¼¼ãã¢ããã¼ãã¨ãªã£ã¦ããï¼</p><p>Deep Matchingã使ãã¨ä»¥ä¸ã®ããã«éåä½ã®ãããã³ã°ããã¾ãåºæ¥ãããã§ããï¼</p>
<blockquote cite="http://lear.inrialpes.fr/people/revaud/">
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140821/20140821152916.png" alt="f:id:whoopsidaisies:20140821152916p:plain" title="f:id:whoopsidaisies:20140821152916p:plain" class="hatena-fotolife" itemprop="image"></span><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140821/20140821152927.png" alt="f:id:whoopsidaisies:20140821152927p:plain" title="f:id:whoopsidaisies:20140821152927p:plain" class="hatena-fotolife" itemprop="image"></span></p>
<cite><a href="http://lear.inrialpes.fr/people/revaud/"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Flear.inrialpes.fr%2Fpeople%2Frevaud%2F" alt="" class="http-favicon" /></a><a href="http://lear.inrialpes.fr/people/revaud/">Jerome Revaud</a></cite>
</blockquote>
</div>
</div>
<div class="section">
<h3>ãªããã£ã«ã«ããã¼</h3>
<p>DeepFlowã§ã¯ï¼æéçè¼åº¦å¾é
ã¨ç©ºéçè¼åº¦å¾é
ã®æææ¡ä»¶ã«å ãã¦ï¼Deep Matchingã§æ±ãã対å¿ã¨ãªããã£ã«ã«ããã¼ã¨ã®å·®ç°ãæææ¡ä»¶ã¨ãã¦ç®çé¢æ°ã«å
¥ãããã¨ã§ï¼å¯ã§ãã¤å¤§ããªåãã«ãå¼·ããªããã£ã«ã«ããã¼ãå¾ãããã§ããï¼</p><p>ç®çé¢æ°ã®æå°åã¯<a href="http://ja.wikipedia.org/wiki/SOR%E6%B3%95">SOR法</a>ã¨ããå復æ³ã§è¡ã£ã¦ããããã§ããï¼</p><p>DeepFlowã§ä»¥ä¸ã®ç»åã¿ãããªæãã«ãããã³ã°ã¨ãªããã£ã«ã«ããã¼ãå¾ããããããï¼</p>
<blockquote cite="http://lear.inrialpes.fr/src/deepmatching/">
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140821/20140821180059.png" alt="f:id:whoopsidaisies:20140821180059p:plain" title="f:id:whoopsidaisies:20140821180059p:plain" class="hatena-fotolife" itemprop="image"></span></p>
<cite><a href="http://lear.inrialpes.fr/src/deepmatching/"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Flear.inrialpes.fr%2Fsrc%2Fdeepmatching%2F" alt="" class="http-favicon" /></a><a href="http://lear.inrialpes.fr/src/deepmatching/">LEAR - DeepMatchingFlow</a></cite>
</blockquote>
</div>
<div class="section">
<h3>OpenCVã§åããã¦ã¿ã</h3>
<p>DeepFlowã¯2014/8/21ç¾å¨<a href="https://github.com/Itseez/opencv_contrib">opencv_contrib</a>ã«å
¥ã£ã¦ãããï¼opencv_contribã¯éçºç¨ãªãã¸ããªãããã®ã§èªå·±è²¬ä»»ã§ï¼</p><p><a href="https://github.com/Itseez/opencv_contrib">ここ</a>ããã½ã¼ã¹ãè½ã¨ãã¦ãã¦ï¼OpenCVã®CMakeã®ãªãã·ã§ã³ã§ãOPENCV_EXTRA_MODULES_PATHãããï¼opencv_contribã®ãã¹ï¼/modulesãã¨ãã¦generateï¼ãã«ããã¦ããã¨OpenCVã«opencv_contribå
ã®ã¢ã¸ã¥ã¼ã«ãçµã¿è¾¼ã¾ããï¼</p><p>å®éã«DeepFlowãåããã¦ã¿ãã½ã¼ã¹ã³ã¼ãã¯ä»¥ä¸ï¼<br />
DeepFlowã®ãã©ã¡ã¼ã¿ã¯<a href="http://docs.opencv.org/3.0-alpha/modules/optflow/doc/dense_optflow.html?highlight=deepflow#optflow::OpticalFlowDeepFlow: public DenseOpticalFlow">ここ</a>ãåç
§ï¼</p>
<pre class="code lang-cpp" data-lang="cpp" data-unlink><span class="synPreProc">#include </span><span class="synConstant"><opencv2/opencv.hpp></span>
<span class="synPreProc">#include </span><span class="synConstant"><opencv2/optflow.hpp></span>
<span class="synType">void</span> main()
{
<span class="synStatement">using</span> <span class="synType">namespace</span> cv;
<span class="synComment">// DeepFlowè¨ç®ç¨ã®ã¤ã³ã¹ã¿ã³ã¹ãçæ</span>
<span class="synType">auto</span> deepflow = optflow::createOptFlow_DeepFlow();
<span class="synComment">// åç»èªã¿è¾¼ã¿</span>
<span class="synType">auto</span> capture = VideoCapture(<span class="synConstant">"video.mp4"</span>);
<span class="synComment">// åã®ãã¬ã¼ã ä¿å</span>
<span class="synComment">// ã¾ã ã°ã¬ã¼ã¹ã±ã¼ã«ãã対å¿ãã¦ãªããããªã®ã§å¤æ</span>
Mat prev, tmp;
capture >> tmp;
cvtColor(tmp, prev, COLOR_RGB2GRAY);
<span class="synStatement">while</span> (cv::waitKey(<span class="synConstant">1</span>) == -<span class="synConstant">1</span>)
{
Mat curr;
capture >> tmp;
<span class="synStatement">if</span> (tmp.empty())
<span class="synStatement">break</span>;
cvtColor(tmp, curr, COLOR_RGB2GRAY);
<span class="synComment">// ãªããã£ã«ã«ããã¼ã®è¨ç®</span>
Mat flow;
deepflow->calc(prev, curr, flow);
<span class="synComment">// 表示ããããã«Xæåã¨Yæåã«å解</span>
Mat flowXY[<span class="synConstant">2</span>];
split(flow, flowXY);
<span class="synComment">// 極座æ¨ã«å¤æ</span>
Mat magnitude, angle;
cartToPolar(flowXY[<span class="synConstant">0</span>], flowXY[<span class="synConstant">1</span>], magnitude, angle, <span class="synConstant">true</span>);
<span class="synComment">// è²ç¸ï¼Hï¼ã¯ãªããã£ã«ã«ããã¼ã®è§åº¦</span>
<span class="synComment">// 彩度ï¼Sï¼ã¯0ï½1ã«æ£è¦åãããªããã£ã«ã«ããã¼ã®å¤§ãã</span>
<span class="synComment">// æ度ï¼Vï¼ã¯1</span>
Mat hsvPlanes[<span class="synConstant">3</span>];
hsvPlanes[<span class="synConstant">0</span>] = angle;
hsvPlanes[<span class="synConstant">1</span>] = magnitude;
hsvPlanes[<span class="synConstant">2</span>] = Mat::ones(angle.size(), CV_32F);
<span class="synComment">// HSVãåæãã¦ä¸æã®ç»åã«ãã</span>
Mat hsv;
merge(hsvPlanes, <span class="synConstant">3</span>, hsv);
<span class="synComment">// 表示</span>
imshow(<span class="synConstant">"DeepFlow"</span>, hsv);
<span class="synComment">// åã®ãã¬ã¼ã ãä¿å</span>
prev = curr;
}
}
</pre><p>çµæã¯ãããªæãï¼ããªãæéããã£ãï¼<br />
ã¡ããã¡ããçã£èµ¤ã«ãªãã®ã¯ä»æ§ãªã®ããã°ãªã®ãï¼</p><p><iframe width="420" height="315" frameborder="0" allowfullscreen="" src="https://youtube.googleapis.com/v/pCoA0dc9gGE&feature&source=uds"></iframe><br><a href="http://www.youtube.com/watch?v=pCoA0dc9gGE&feature">OpenCVã§DeepFlow - YouTube</a></p>
</div>
whoopsidaisies
OpenCV3.0.0-alphaã®ç¹å¾´æ½åºã»ãããã³ã°ã¾ã¨ã
hatenablog://entry/12921228815730771882
2014-08-20T20:02:15+09:00
2014-08-20T20:02:15+09:00 OpenCV3.0.0-alphaã®ããã±ã¼ã¸ãå
¬éãããã¨è©±é¡ã«ãªã£ã¦ããã®ã§ä½¿ã£ã¦ã¿ãï¼Change Logãè¦ãã¨AKAZEç¹å¾´éãçµã¿è¾¼ã¾ãã¦ããï¼ AKAZEç¹å¾´éã®ç´¹ä»ã¨ä»ç¹å¾´éã¨ã®æ¯è¼ - é¥ãã¸ã®ã¹ãã¼ãã©ã³ãã¼ ã«ããã¨AKAZEç¹å¾´éã¯ï¼ä»¥åã®OpenCVã§ãakaze-opencvã¨ããããã±ã¼ã¸ãå
¥ããã°ä½¿ãããï¼OpenCV3.0.0-alphaã§ã¯å
ã
çµã¿è¾¼ã¾ãã¦ããã®ã§ãã®ã¾ã¾ä½¿ããããã ï¼éã«SIFTãSURFãªããã¯å
ã
OpenCVã§ä½¿ããã OpenCV 3.0.0-alphaã§SIFT/SURFã使ã | .COM-POUND ã«ããã¨ï¼opencv_coâ¦
<p>OpenCV3.0.0-alphaã®ããã±ã¼ã¸ã<a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0-alpha/">公開された</a>ã¨è©±é¡ã«ãªã£ã¦ããã®ã§ä½¿ã£ã¦ã¿ãï¼</p><p><a href="http://code.opencv.org/projects/opencv/wiki/ChangeLog#30-alpha">Change Log</a>ãè¦ãã¨AKAZEç¹å¾´éãçµã¿è¾¼ã¾ãã¦ããï¼<br />
<a href="http://poly.hatenablog.com/entry/2014/01/06/063012"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fpoly.hatenablog.com%2Fentry%2F2014%2F01%2F06%2F063012" alt="" class="http-favicon" /></a><a href="http://poly.hatenablog.com/entry/2014/01/06/063012">AKAZE特徴量の紹介と他特徴量との比較 - 遥かへのスピードランナー</a><br />
ã«ããã¨AKAZEç¹å¾´éã¯ï¼ä»¥åã®OpenCVã§ã<a href="https://github.com/thorikawa/akaze-opencv">akaze-opencv</a>ã¨ããããã±ã¼ã¸ãå
¥ããã°ä½¿ãããï¼OpenCV3.0.0-alphaã§ã¯å
ã
çµã¿è¾¼ã¾ãã¦ããã®ã§ãã®ã¾ã¾ä½¿ããããã ï¼</p><p>éã«SIFTãSURFãªããã¯å
ã
OpenCVã§ä½¿ããã<br />
<a href="http://www.yasutomo57jp.com/2014/08/19/opencv-3-0-0-alpha%E3%81%A7siftsurf%E3%82%92%E4%BD%BF%E3%81%86/"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwww.yasutomo57jp.com%2F2014%2F08%2F19%2Fopencv-3-0-0-alpha%25E3%2581%25A7siftsurf%25E3%2582%2592%25E4%25BD%25BF%25E3%2581%2586%2F" alt="" class="http-favicon" /></a><a href="http://www.yasutomo57jp.com/2014/08/19/opencv-3-0-0-alpha%E3%81%A7siftsurf%E3%82%92%E4%BD%BF%E3%81%86/">OpenCV 3.0.0-alphaでSIFT/SURFを使う | .COM-POUND</a><br />
ã«ããã¨ï¼<a href="https://github.com/Itseez/opencv_contrib">opencv_contrib</a>ã«ç§»åããã¦ãã¾ãOpenCVã¨ä¸ç·ã«ãã«ãããªãã¨ä½¿ããªãããã§ããï¼</p>
<div class="section">
<h3>OpenCV3.0.0-alphaã§ã®å¤æ´ç¹ã¾ã¨ã</h3>
<p>以åå½ããã°ã§<br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/07/135810"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2013%2F12%2F07%2F135810" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/07/135810">OpenCVで画像の特徴抽出・マッチングを行う - whoopsidaisies's diary</a><br />
ã«OpenCV2.4.7ã®ç»åã®ç¹å¾´æ½åºããããã¾ã¨ããè¨äºãæ¸ãã¦ããã®ã§ï¼ä»åã¯OpenCV3.0.0-alphaã§ã®å¤æ´ç¹ãã¾ã¨ãã¦ã¿ãï¼</p>
<div class="section">
<h4>ç¹å¾´ç¹æ½åºï¼FeatureDetectorã¤ã³ã¿ã¼ãã§ã¼ã¹ï¼</h4>
<table>
<tr>
<td></td>
<th>FeatureDetector</th>
</tr>
<tr>
<th>OpenCV2.4.7</th>
<td>FASTï¼<span style="color: #c0c0c0">FASTX</span>ï¼<span style="color: #0000ff">STAR</span>ï¼<span style="color: #0000ff">SIFT</span>ï¼<span style="color: #0000ff">SURF</span>ï¼ORBï¼BRISKï¼MSERï¼GFTTï¼HARRISï¼<span style="color: #c0c0c0">Dense</span>ï¼SimpleBlob</td>
</tr>
<tr>
<th>OpenCV3.0.0-alpha</th>
<td>FASTï¼ORBï¼BRISKï¼MSERï¼GFTTï¼HARRISï¼SimpleBlobï¼<span style="color: #ff0000">KAZE</span>ï¼<span style="color: #ff0000">AKAZE</span></td>
</tr>
<tr>
<th>opencv_contrib</th>
<td>STARï¼SIFTï¼SURF</td>
</tr>
</table><p><span style="color: #ff0000">赤å</span>ã¯OpenCV3.0.0-alphaã§è¿½å ããããã®ï¼<br />
<span style="color: #0000ff">éå</span>ã¯opencv_contribãå
¥ããã°ä½¿ãããã®ï¼<br />
<span style="color: #c0c0c0">ç°è²</span>ã¯OpenCV3.0.0-alphaã§ãªããªã£ã¦ãã¾ã£ã¦opencv_contribã«ãå
¥ã£ã¦ãªããã®ï¼</p><p>FASTXã¨Denseã¯ãªããªã£ã¦ãã¾ã£ãããã§ããï¼</p>
</div>
<div class="section">
<h4>ç¹å¾´è¨è¿°ï¼DescriptorExtractorã¤ã³ã¿ã¼ãã§ã¼ã¹ï¼</h4>
<table>
<tr>
<td></td>
<th>DescriptorExtractor</th>
</tr>
<tr>
<th>OpenCV2.4.7</th>
<td><span style="color: #0000ff">SIFT</span>ï¼<span style="color: #0000ff">SURF</span>ï¼<span style="color: #0000ff">BRIEF</span>ï¼BRISKï¼ORBï¼<span style="color: #0000ff">FRIEK</span></td>
</tr>
<tr>
<th>OpenCV3.0.0-alpha</th>
<td>BRISKï¼ORBï¼<span style="color: #ff0000">KAZE</span>ï¼<span style="color: #ff0000">AKAZE</span></td>
</tr>
<tr>
<th>opencv_contrib</th>
<td>SIFTï¼SURFï¼BRIEFï¼FREAK</td>
</tr>
</table><p><span style="color: #ff0000">赤å</span>ã¯OpenCV3.0.0-alphaã§è¿½å ããããã®ï¼<br />
<span style="color: #0000ff">éå</span>ã¯opencv_contribãå
¥ããã°ä½¿ãããã®ï¼</p>
</div>
<div class="section">
<h4>ç¹å¾´ç¹ãããã³ã°ï¼DescriptorMatcherã¤ã³ã¿ã¼ãã§ã¼ã¹ï¼</h4>
<table>
<tr>
<td></td>
<th>DescriptorExtractor</th>
</tr>
<tr>
<td>OpenCV2.4.7ããã³OpenCV3.0.0-alpha</td>
<td>BruteForceï¼BruteForce-L1ï¼BruteForce-SL2ï¼BruteForce-Hammingï¼BruteForce-Hamming(2)ï¼FlannBased</td>
</tr>
</table><p>DescriptorMatcherã«é¢ãã¦ã¯å¤ããããªãããã§ããï¼</p>
</div>
</div>
<div class="section">
<h3>AKAZEã使ã£ã¦ã¿ã</h3>
<p>AKAZEã使ã£ã¦ã¿ããã£ãã®ã§ï¼OpenCV3.0.0-alphaã§ç¹å¾´æ½åºãè¡ã£ã¦ã¿ãï¼ã¤ãã§ã«ä»ã®ã¢ã«ã´ãªãºã ã¨ãç»åãæ¯è¼ãã¦ã¿ãï¼ç¹å¾´æ½åºã®ã½ã¼ã¹ã³ã¼ãã¯ä»¥ä¸ï¼</p>
<pre class="code lang-cpp" data-lang="cpp" data-unlink>cv::String detectorNames[] = {<span class="synConstant">"AKAZE"</span>, <span class="synConstant">"KAZE"</span>, <span class="synConstant">"FAST"</span>, <span class="synConstant">"ORB"</span>, <span class="synConstant">"BRISK"</span>, <span class="synConstant">"MSER"</span>, <span class="synConstant">"GFTT"</span>, <span class="synConstant">"HARRIS"</span>, <span class="synConstant">"SimpleBlob"</span>,};
<span class="synType">auto</span> img = cv::imread(<span class="synConstant">"Penguins.jpg"</span>);
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < <span class="synConstant">9</span>; i++)
{
<span class="synType">auto</span> detector = cv::FeatureDetector::create(detectorNames[i]);
std::vector<cv::KeyPoint> keyPoints;
detector->detect(img, keyPoints);
cv::Mat output;
cv::drawKeypoints(img, keyPoints, output, cv::Scalar::all(-<span class="synConstant">1</span>),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
cv::imwrite(detectorNames[i] + <span class="synConstant">".bmp"</span>, output);
}
</pre><p><hr></p>
<div class="section">
<h5>AKAZE</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194415.jpg" alt="f:id:whoopsidaisies:20140820194415j:plain" title="f:id:whoopsidaisies:20140820194415j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<hr></p>
</div>
<div class="section">
<h5>KAZE</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194424.jpg" alt="f:id:whoopsidaisies:20140820194424j:plain" title="f:id:whoopsidaisies:20140820194424j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<hr></p>
</div>
<div class="section">
<h5>FAST</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194432.jpg" alt="f:id:whoopsidaisies:20140820194432j:plain" title="f:id:whoopsidaisies:20140820194432j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<hr></p>
</div>
<div class="section">
<h5>ORB</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194437.jpg" alt="f:id:whoopsidaisies:20140820194437j:plain" title="f:id:whoopsidaisies:20140820194437j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<hr></p>
</div>
<div class="section">
<h5>BRISK</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194444.jpg" alt="f:id:whoopsidaisies:20140820194444j:plain" title="f:id:whoopsidaisies:20140820194444j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<hr></p>
</div>
<div class="section">
<h5>MSER</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194454.jpg" alt="f:id:whoopsidaisies:20140820194454j:plain" title="f:id:whoopsidaisies:20140820194454j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<hr></p>
</div>
<div class="section">
<h5>GFTT</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194459.jpg" alt="f:id:whoopsidaisies:20140820194459j:plain" title="f:id:whoopsidaisies:20140820194459j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<hr></p>
</div>
<div class="section">
<h5>HARRIS</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194510.jpg" alt="f:id:whoopsidaisies:20140820194510j:plain" title="f:id:whoopsidaisies:20140820194510j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<hr></p>
</div>
<div class="section">
<h5>SimpleBlog</h5>
<p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140820/20140820194515.jpg" alt="f:id:whoopsidaisies:20140820194515j:plain" title="f:id:whoopsidaisies:20140820194515j:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
</div>
whoopsidaisies
C#ã§Deep Learningï¼Accord.NETã«ããæ¹æ³ï¼
hatenablog://entry/12921228815730581582
2014-08-19T01:54:20+09:00
2014-08-19T01:54:20+09:00 æµè¡ãã®Deep LearningãC#ã§è©¦ãã¦ã¿ãï¼æ©æ¢°å¦ç¿ãã³ã³ãã¥ã¼ã¿ãã¸ã§ã³ï¼ä¿¡å·å¦ççã®.NETåãã®ãªã¼ãã³ã½ã¼ã¹ã®ã©ã¤ãã©ãªã§ããAccord.NET Frameworkã«Deep Learningãå®è£
ããã¦ããã®ã§ããã使ãï¼Deep Belief Networks(DBN), Deep Neural Networks(DNNs)ã¨ãã¾ãã«Restricted Boltzmann Machine(RBM)ãåä½ã§åããã¦ã¿ãï¼Deep Learningèªä½ã«ã¤ãã¦ã¯ä»¥ä¸ã®ãã¼ã¸çãåèã«ï¼ MIRU2014 tutorial deeplearning Deep Learninâ¦
<p>æµè¡ãã®Deep LearningãC#ã§è©¦ãã¦ã¿ãï¼æ©æ¢°å¦ç¿ãã³ã³ãã¥ã¼ã¿ãã¸ã§ã³ï¼ä¿¡å·å¦ççã®.NETåãã®ãªã¼ãã³ã½ã¼ã¹ã®ã©ã¤ãã©ãªã§ãã<a href="http://accord-framework.net/">Accord.NET Framework</a>ã«Deep Learningãå®è£
ããã¦ããã®ã§ããã使ãï¼</p><p>Deep Belief Networks(DBN), Deep Neural Networks(DNNs)ã¨ãã¾ãã«Restricted Boltzmann Machine(RBM)ãåä½ã§åããã¦ã¿ãï¼</p><p>Deep Learningèªä½ã«ã¤ãã¦ã¯ä»¥ä¸ã®ãã¼ã¸çãåèã«ï¼<br />
<a href="http://www.slideshare.net/Takayosi/miru2014-tutorial-deeplearning-37219713"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwww.slideshare.net%2FTakayosi%2Fmiru2014-tutorial-deeplearning-37219713" alt="" class="http-favicon" /></a><a href="http://www.slideshare.net/Takayosi/miru2014-tutorial-deeplearning-37219713">MIRU2014 tutorial deeplearning</a><br />
<a href="http://www.slideshare.net/beam2d/deep-learning20140130"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwww.slideshare.net%2Fbeam2d%2Fdeep-learning20140130" alt="" class="http-favicon" /></a><a href="http://www.slideshare.net/beam2d/deep-learning20140130">Deep Learning技術の今</a><br />
<a href="http://www.vision.is.tohoku.ac.jp/files/9313/6601/7876/CVIM_tutorial_deep_learning.pdf"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwww.vision.is.tohoku.ac.jp%2Ffiles%2F9313%2F6601%2F7876%2FCVIM_tutorial_deep_learning.pdf" alt="" class="http-favicon" /></a><a href="http://www.vision.is.tohoku.ac.jp/files/9313/6601/7876/CVIM_tutorial_deep_learning.pdf">ディープラーニング チュートリアル(もしくは研究動向報告)</a><br />
</p>
<div class="section">
<h3>Accord.NETã®ã¤ã³ã¹ãã¼ã«</h3>
<p>NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããAccord.Neuroããæ¤ç´¢ã»ã¤ã³ã¹ãã¼ã«ï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140819/20140819013518.png" alt="f:id:whoopsidaisies:20140819013518p:plain" title="f:id:whoopsidaisies:20140819013518p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>ã½ã¼ã¹ã³ã¼ã</h3>
<ul>
<li><a href="#dbn1">Deep Belief Networks(DBN) - æ師ããå¦ç¿(Back propagation)</a></li>
<li><a href="#dbn2">Deep Belief Networks(DBN) - æ師ãªãå¦ç¿(Contrastive Divergence)</a></li>
<li><a href="#dnn">Deep Neural Networks(DNNs)</a></li>
<li><a href="#rbm">Restricted Boltzmann Machine(RBM)</a></li>
</ul><p>ãåãããµã³ãã«ã³ã¼ããè¼ãã¦ãããï¼ãããã®ãµã³ãã«ã§ã以ä¸ã®usingãæ¸ãã¦ãããã¨ï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synStatement">using</span> Accord.Neuro;
<span class="synStatement">using</span> Accord.Neuro.Networks;
<span class="synStatement">using</span> Accord.Neuro.Learning;
<span class="synStatement">using</span> AForge.Neuro.Learning;
<span class="synStatement">using</span> Accord.Neuro.ActivationFunctions;
<span class="synStatement">using</span> Accord.Math;
</pre><p><a name = "dbn1"></a></p>
</div>
<div class="section">
<h3>Deep Belief Networks(DBN) - æ師ããå¦ç¿(Back propagation)</h3>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// ãã¬ã¼ãã³ã°ãã¼ã¿</span>
<span class="synType">double</span>[][] inputs = {
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> },
};
<span class="synType">double</span>[][] outputs = {
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
};
<span class="synComment">// DBNã®çæ</span>
var network = <span class="synStatement">new</span> DeepBeliefNetwork(
<span class="synStatement"> inputsCount:</span> inputs.Length, <span class="synComment">// å
¥å層ã®æ¬¡å
</span>
<span class="synStatement"> hiddenNeurons:</span> <span class="synStatement">new</span> <span class="synType">int</span>[] { <span class="synConstant">4</span>, <span class="synConstant">2</span> }); <span class="synComment">// é ã層ã¨åºå層ã®æ¬¡å
</span>
<span class="synComment">// ãããã¯ã¼ã¯ã®éã¿ãã¬ã¦ã¹åå¸ã§åæåãã</span>
<span class="synStatement">new</span> GaussianWeights(network).Randomize();
network.UpdateVisibleWeights();
<span class="synComment">// DBNã®å¦ç¿ã¢ã«ã´ãªãºã ã®çæ 5000åç¹°ãè¿ãå
¥å</span>
var teacher = <span class="synStatement">new</span> BackPropagationLearning(network);
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < <span class="synConstant">5000</span>; i++)
teacher.RunEpoch(inputs, outputs);
<span class="synComment">// éã¿ã®æ´æ°</span>
network.UpdateVisibleWeights();
<span class="synComment">// å¦ç¿ããããããã¯ã¼ã¯ã§ãã¹ããã¼ã¿ãåã¯ã©ã¹ã«å±ãã確çãè¨ç®</span>
<span class="synType">double</span>[] input = { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> };
var output = network.Compute(input);
<span class="synComment">// ä¸çªç¢ºçã®é«ãã¯ã©ã¹ã®ã¤ã³ããã¯ã¹ãå¾ã</span>
<span class="synType">int</span> imax; output.Max(<span class="synStatement">out</span> imax);
<span class="synComment">// çµæåºå</span>
Console.WriteLine(<span class="synConstant">"class : {0}"</span>, imax);
<span class="synStatement">foreach</span> (var o <span class="synStatement">in</span> output)
{
Console.Write(<span class="synConstant">"{0} "</span>, o);
}
</pre><p>å®è¡çµæ</p>
<pre class="code" data-lang="" data-unlink>class : 0
0.883118949465337 0.115560850111682</pre><p><a name="#dbn2"></a></p>
</div>
<div class="section">
<h3>Deep Belief Networks(DBN) - æ師ãªãå¦ç¿(Contrastive Divergence)</h3>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// ãã¬ã¼ãã³ã°ãã¼ã¿</span>
<span class="synType">double</span>[][] inputs = {
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> },
};
<span class="synComment">// DBNã®çæ</span>
var network = <span class="synStatement">new</span> DeepBeliefNetwork(
<span class="synStatement"> inputsCount:</span> <span class="synConstant">6</span>,
<span class="synStatement"> hiddenNeurons:</span> <span class="synStatement">new</span> <span class="synType">int</span>[] { <span class="synConstant">4</span>, <span class="synConstant">2</span> });
<span class="synComment">// ãããã¯ã¼ã¯ã®éã¿ãã¬ã¦ã¹åå¸ã§åæåãã</span>
<span class="synStatement">new</span> GaussianWeights(network).Randomize();
network.UpdateVisibleWeights();
<span class="synComment">// DBNã®å¦ç¿ã¢ã«ã´ãªãºã ã®çæ 5000åç¹°ãè¿ãå
¥å</span>
var teacher = <span class="synStatement">new</span> DeepBeliefNetworkLearning(network)
{
Algorithm = (h, v, i) => <span class="synStatement">new</span> ContrastiveDivergenceLearning(h, v)
};
var layerData = teacher.GetLayerInput(inputs);
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < <span class="synConstant">5000</span>; i++)
teacher.RunEpoch(layerData);
<span class="synComment">// éã¿ã®æ´æ°</span>
network.UpdateVisibleWeights();
<span class="synComment">// å¦ç¿ããããããã¯ã¼ã¯ã§ãã¹ããã¼ã¿ãåã¯ã©ã¹ã«å±ãã確çãè¨ç®</span>
<span class="synType">double</span>[] input = { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> };
var output = network.Compute(input);
<span class="synComment">// ä¸çªç¢ºçã®é«ãã¯ã©ã¹ã®ã¤ã³ããã¯ã¹ãå¾ã</span>
<span class="synType">int</span> imax; output.Max(<span class="synStatement">out</span> imax);
<span class="synComment">// çµæåºå</span>
Console.WriteLine(<span class="synConstant">"class : {0}"</span>, imax);
<span class="synStatement">foreach</span> (var o <span class="synStatement">in</span> output)
{
Console.Write(<span class="synConstant">"{0} "</span>, o);
}
</pre><p>å®è¡çµæ</p>
<pre class="code" data-lang="" data-unlink>class : 1
0.529437183967883 0.554114047128916</pre><p><a name="#dnn"></a></p>
</div>
<div class="section">
<h3>Deep Neural Networks(DNNs)</h3>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// ãã¬ã¼ãã³ã°ãã¼ã¿</span>
<span class="synType">double</span>[][] inputs = {
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> },
};
<span class="synType">double</span>[][] outputs = {
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
};
<span class="synComment">// ãããã¯ã¼ã¯ã®çæ</span>
var network = <span class="synStatement">new</span> DeepBeliefNetwork(
<span class="synStatement"> inputsCount:</span> inputs.Length, <span class="synComment">// å
¥å層ã®æ¬¡å
</span>
<span class="synStatement"> hiddenNeurons:</span> <span class="synStatement">new</span> <span class="synType">int</span>[] { <span class="synConstant">4</span>, <span class="synConstant">2</span> }); <span class="synComment">// é ã層ã¨åºå層ã®æ¬¡å
</span>
<span class="synComment">// DNNã®å¦ç¿ã¢ã«ã´ãªãºã ã®çæ</span>
var teacher = <span class="synStatement">new</span> DeepNeuralNetworkLearning(network)
{
Algorithm = (ann, i) => <span class="synStatement">new</span> ParallelResilientBackpropagationLearning(ann),
LayerIndex = network.Machines.Count - <span class="synConstant">1</span>,
};
<span class="synComment">// 5000åç¹°ãè¿ãå¦ç¿</span>
var layerData = teacher.GetLayerInput(inputs);
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < <span class="synConstant">5000</span>; i++)
teacher.RunEpoch(layerData, outputs);
<span class="synComment">// éã¿ã®æ´æ°</span>
network.UpdateVisibleWeights();
<span class="synComment">// å¦ç¿ããããããã¯ã¼ã¯ã§ãã¹ããã¼ã¿ãåã¯ã©ã¹ã«å±ãã確çãè¨ç®</span>
<span class="synType">double</span>[] input = { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> };
var output = network.Compute(input);
<span class="synComment">// ä¸çªç¢ºçã®é«ãã¯ã©ã¹ã®ã¤ã³ããã¯ã¹ãå¾ã</span>
<span class="synType">int</span> imax; output.Max(<span class="synStatement">out</span> imax);
<span class="synComment">// çµæåºå</span>
Console.WriteLine(<span class="synConstant">"class : {0}"</span>, imax);
<span class="synStatement">foreach</span> (var o <span class="synStatement">in</span> output)
{
Console.Write(<span class="synConstant">"{0} "</span>, o);
}
</pre><p>å®è¡çµæ</p>
<pre class="code" data-lang="" data-unlink>class : 0
0.999680477117216 0.00120961077917418</pre><p><a name="#rbm"></a></p>
</div>
<div class="section">
<h3>Restricted Boltzmann Machine(RBM)</h3>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// ãã¬ã¼ãã³ã°ãã¼ã¿</span>
<span class="synType">double</span>[][] inputs = {
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">0</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span> },
};
<span class="synType">double</span>[][] outputs = {
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">1</span>, <span class="synConstant">0</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
<span class="synStatement">new</span> <span class="synType">double</span>[] { <span class="synConstant">0</span>, <span class="synConstant">1</span> },
};
<span class="synComment">// RBMã®çæ</span>
var rbm = <span class="synStatement">new</span> RestrictedBoltzmannMachine(
<span class="synStatement"> inputsCount:</span> <span class="synConstant">6</span>,
<span class="synStatement"> hiddenNeurons:</span> <span class="synConstant">2</span>);
<span class="synComment">// ãã¬ã¼ãã³ã°ãã¼ã¿ã§å¦ç¿</span>
var teacher = <span class="synStatement">new</span> ContrastiveDivergenceLearning(rbm);
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < <span class="synConstant">5000</span>; i++)
teacher.RunEpoch(inputs);
<span class="synComment">// ãã¹ããã¼ã¿</span>
<span class="synType">double</span>[] input = { <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">1</span>, <span class="synConstant">0</span>, <span class="synConstant">0</span> };
<span class="synComment">// å¦ç¿ããããããã¯ã¼ã¯ã§åã¯ã©ã¹ã«å±ãã確çãè¨ç®</span>
var output = rbm.Compute(input);
<span class="synComment">// ä¸çªç¢ºçã®é«ãã¯ã©ã¹ã®ã¤ã³ããã¯ã¹ãå¾ã</span>
<span class="synType">int</span> imax; output.Max(<span class="synStatement">out</span> imax);
<span class="synComment">// çµæåºå</span>
Console.WriteLine(<span class="synConstant">"class : {0}"</span>, imax);
<span class="synStatement">foreach</span> (var o <span class="synStatement">in</span> output)
{
Console.Write(<span class="synConstant">"{0} "</span>, o);
}
</pre><p>å®è¡çµæ</p>
<pre class="code" data-lang="" data-unlink>class : 1
0.133832413712274 0.906343089146992</pre>
</div>
whoopsidaisies
C#ã§SVMãlibsvm.netã«ããæ¹æ³
hatenablog://entry/12921228815730367189
2014-08-16T18:30:02+09:00
2014-08-16T18:30:02+09:00 SVMã®ã©ã¤ãã©ãªã§ããLIBSVMã.NETããã¸ã§ã¯ãã§ä½¿ããããã«ããlibsvm.netãåããã¦ã¿ãï¼ libsvm.netã®ã¤ã³ã¹ãã¼ã« NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããlibsvm.netããæ¤ç´¢ã»ã¤ã³ã¹ãã¼ã«ï¼ åä½ç¢ºèª libsvm.netã§ã¯ï¼ãã¬ã¼ãã³ã°ãã¼ã¿ããã¹ããã¼ã¿ãLIBSVMã¨åãå½¢å¼ã§ãã¡ã¤ã«ããå
¥åã§ããï¼ãã¼ã¿ã®ãã©ã¼ãããã¯ä»¥ä¸ã®éãã§ããï¼ <label> <index1>:<value1> <index2>:<value2> ... <iâ¦
<p>SVMã®ã©ã¤ãã©ãªã§ãã<a href="http://www.csie.ntu.edu.tw/~cjlin/libsvm/">LIBSVM</a>ã.NETããã¸ã§ã¯ãã§ä½¿ããããã«ãã<a href="https://code.google.com/p/libsvm-net/">libsvm.net</a>ãåããã¦ã¿ãï¼</p>
<div class="section">
<h3>libsvm.netã®ã¤ã³ã¹ãã¼ã«</h3>
<p>NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããlibsvm.netããæ¤ç´¢ã»ã¤ã³ã¹ãã¼ã«ï¼</p>
</div>
<div class="section">
<h3>åä½ç¢ºèª</h3>
<p>libsvm.netã§ã¯ï¼ãã¬ã¼ãã³ã°ãã¼ã¿ããã¹ããã¼ã¿ãLIBSVMã¨åãå½¢å¼ã§ãã¡ã¤ã«ããå
¥åã§ããï¼ãã¼ã¿ã®ãã©ã¼ãããã¯ä»¥ä¸ã®éãã§ããï¼</p>
<blockquote cite="http://bio-info.biz/tips/libsvm_data_format.html">
<p><label> <index1>:<value1> <index2>:<value2> ... <indexN>:<valueN><br />
<label> <index1>:<value1> <index2>:<value2> ... <indexN>:<valueN><br />
<label> <index1>:<value1> <index2>:<value2> ... <indexN>:<valueN><br />
.<br />
.<br />
.<br />
<label> <index1>:<value1> <index2>:<value2> ... <indexN>:<valueN></p>
<cite><a href="http://bio-info.biz/tips/libsvm_data_format.html">LIBSVMの入力データ形式について</a></cite>
</blockquote>
<p><a href="http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/">ここ</a>ã«LIBSVMç¨ã®ãã¼ã¿ã»ãããè½ã¡ã¦ããã®ã§ï¼<a href="http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary.html#fourclass">fourclass</a>ã¨ãããã¼ã¿ã»ããã使ã£ã¦ã¿ãï¼</p><p>以ä¸ã«ï¼åé¡å¨ãåããã½ã¼ã¹ã³ã¼ãä¹ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">// ãã¬ã¼ãã³ã°ãã¼ã¿ã®èªã¿è¾¼ã¿</span>
var training = libsvm.ProblemHelper.ReadProblem(<span class="synConstant">"fourclass"</span>);
<span class="synComment">// RBFã«ã¼ãã«ãçæ</span>
var gamma = <span class="synConstant">1</span>;
var kernel = libsvm.KernelHelper.RadialBasisFunctionKernel(gamma);
<span class="synComment">// C-SVCç¨ã®ã¯ã©ã¹ã®çæ</span>
var c = <span class="synConstant">1</span>;
var svm = <span class="synStatement">new</span> libsvm.C_SVC(training, kernel, c);
<span class="synComment">// ãã¹ããã¼ã¿ã®èªã¿è¾¼ã¿ï¼é¢åã ã£ãã®ã§ãã¬ã¼ãã³ã°ãã¼ã¿ããã®ã¾ã¾ä½¿ã£ã¦ãï¼</span>
var test = libsvm.ProblemHelper.ReadProblem(<span class="synConstant">"fourclass"</span>);
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < test.l; i++)
{
<span class="synComment">// äºæ¸¬å¤</span>
var z = svm.Predict(test.x[i]);
<span class="synComment">// å
¥åãã¡ã¤ã«ã«ã¤ãã¦ããã©ãã«</span>
var y = test.y[i];
<span class="synComment">// äºæ¸¬å¤ã¨æ£è§£å¤ãåºå</span>
Console.WriteLine(<span class="synConstant">"{0}:{1} {2}"</span>, i, z, y);
}
</pre><p>ãã¬ã¼ãã³ã°ãã¼ã¿ã¨ãã¹ããã¼ã¿ã¯åããã®ã使ã£ãï¼å®è¡ããã¨ï¼äºæ¸¬å¤ã¨æ£è§£å¤ãåºåãããï¼</p><p>ä¸è¨ã³ã¼ãã§ã¯ãã©ã¡ã¼ã¿é¸æã¨ãã¾ã§ã¯è¡ã£ã¦ããªããï¼çµæ§ç°¡åã«ä½¿ãããï¼ä»ã«ãå帰 (ϵ-SVR)ãå¤ãå¤æ¤åº (One-Class SVM) ãåºæ¥ãããã§ããï¼</p>
</div>
whoopsidaisies
C# LINQã§FIRãã£ã«ã¿
hatenablog://entry/12921228815728446895
2014-07-18T23:32:42+09:00
2014-07-18T23:32:42+09:00 LINQã使ã£ãï¼FIRãã£ã«ã¿æ¼ç®ãè¡ãé¢æ°ï¼ ã½ã¼ã¹ã³ã¼ã /// <summary> /// FIRãã£ã«ã¿ãããããã¼ã¿ãè¿ã /// </summary> /// <param name="data">å
¥åãã¼ã¿</param> /// <param name="coefficients">ãã£ã«ã¿ä¿æ°</param> /// <returns>FIRãã£ã«ã¿ãããããã¼ã¿</returns> List<double> FiniteImpulseResponseFilter( List<double> data, List<double> coefficients) { returnâ¦
<p>LINQã使ã£ãï¼FIRãã£ã«ã¿æ¼ç®ãè¡ãé¢æ°ï¼</p>
<div class="section">
<h3>ã½ã¼ã¹ã³ã¼ã</h3>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">summary</span><span class="synIdentifier">></span>
<span class="synComment">/// FIRãã£ã«ã¿ãããããã¼ã¿ãè¿ã</span>
<span class="synComment">/// </span><span class="synIdentifier"></</span><span class="synStatement">summary</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">param</span><span class="synIdentifier"> </span><span class="synType">name</span>=<span class="synConstant">"data"</span><span class="synIdentifier">></span><span class="synComment">å
¥åãã¼ã¿</span><span class="synIdentifier"></</span><span class="synStatement">param</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">param</span><span class="synIdentifier"> </span><span class="synType">name</span>=<span class="synConstant">"coefficients"</span><span class="synIdentifier">></span><span class="synComment">ãã£ã«ã¿ä¿æ°</span><span class="synIdentifier"></</span><span class="synStatement">param</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">returns</span><span class="synIdentifier">></span><span class="synComment">FIRãã£ã«ã¿ãããããã¼ã¿</span><span class="synIdentifier"></</span><span class="synStatement">returns</span><span class="synIdentifier">></span>
List<<span class="synType">double</span>> FiniteImpulseResponseFilter(
List<<span class="synType">double</span>> data,
List<<span class="synType">double</span>> coefficients)
{
<span class="synStatement">return</span> Enumerable.Range(<span class="synConstant">0</span>, data.Count - coefficients.Count)
.Select(i => data.Skip(i).Take(coefficients.Count)
.Zip(coefficients, (d, c) => d * c).Sum())
.ToList();
}
</pre><p><a href="http://whoopsidaisies.hatenablog.com/entry/2014/07/18/225436"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2014%2F07%2F18%2F225436" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2014/07/18/225436">C# LINQで移動平均 - whoopsidaisies's diary</a><br />
ããã¼ã¹ã«ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>.Zip(coefficients, (d, c) => d * c).Sum()
</pre><p>ã®é¨åã§å
¥åãã¼ã¿ã¨ãã£ã«ã¿ä¿æ°ã®ç©åæ¼ç®ãè¡ã£ã¦ããï¼</p>
</div>
whoopsidaisies
C# LINQã§ç§»åå¹³å
hatenablog://entry/12921228815728442770
2014-07-18T22:54:36+09:00
2014-07-18T22:54:36+09:00 LINQã使ã£ãï¼ç§»åå¹³åãè¨ç®ããé¢æ°ï¼ ã½ã¼ã¹ã³ã¼ã /// <summary> /// 移åå¹³åãæ ¼ç´ããé
åãè¿ã /// </summary> /// <param name="data">å
¥åãã¼ã¿</param> /// <param name="num">ä½ååã®å¹³åãã¨ãã</param> /// <returns>移åå¹³åãã¨ã£ããã¼ã¿</returns> List<double> MovingAverage( List<double> data, int num) { return Enumerable.Range(0, data.Count - num) .Selectâ¦
<p>LINQã使ã£ãï¼ç§»åå¹³åãè¨ç®ããé¢æ°ï¼</p>
<div class="section">
<h3>ã½ã¼ã¹ã³ã¼ã</h3>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">summary</span><span class="synIdentifier">></span>
<span class="synComment">/// 移åå¹³åãæ ¼ç´ããé
åãè¿ã</span>
<span class="synComment">/// </span><span class="synIdentifier"></</span><span class="synStatement">summary</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">param</span><span class="synIdentifier"> </span><span class="synType">name</span>=<span class="synConstant">"data"</span><span class="synIdentifier">></span><span class="synComment">å
¥åãã¼ã¿</span><span class="synIdentifier"></</span><span class="synStatement">param</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">param</span><span class="synIdentifier"> </span><span class="synType">name</span>=<span class="synConstant">"num"</span><span class="synIdentifier">></span><span class="synComment">ä½ååã®å¹³åãã¨ãã</span><span class="synIdentifier"></</span><span class="synStatement">param</span><span class="synIdentifier">></span>
<span class="synComment">/// </span><span class="synIdentifier"><</span><span class="synStatement">returns</span><span class="synIdentifier">></span><span class="synComment">移åå¹³åãã¨ã£ããã¼ã¿</span><span class="synIdentifier"></</span><span class="synStatement">returns</span><span class="synIdentifier">></span>
List<<span class="synType">double</span>> MovingAverage(
List<<span class="synType">double</span>> data,
<span class="synType">int</span> num)
{
<span class="synStatement">return</span> Enumerable.Range(<span class="synConstant">0</span>, data.Count - num)
.Select(i => data.Skip(i).Take(num).Average())
.ToList();
}
</pre><p>LINQã®ç·´ç¿ç¨ãªã®ã§å¹çãè¯ããã¨ãã¯ç¥ããªãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>Enumerable.Range(<span class="synConstant">0</span>, data.Count - num)
</pre><p>ã§ï¼0ï½ç·ãã¼ã¿æ°ï¼å¹³åãæ±ããã¨ãã®ãã¼ã¿ã®åæ°ã¾ã§ã®æ´æ°ã®ã·ã¼ã±ã³ã¹ãçæããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>data.Skip(i).Take(num).Average()
</pre><p>ã§ï¼å
¥åãã¼ã¿ã®içªç®ã®ãã¼ã¿ããnumåãã¼ã¿ãæ½åºãã¦å¹³åãã¨ãï¼</p>
</div>
<div class="section">
<h3>ãã®ä»</h3>
<p>FIRãã£ã«ã¿ã¯ä»¥ä¸ã®è¨äºï¼<br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2014/07/18/233242"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2014%2F07%2F18%2F233242" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2014/07/18/233242">C# LINQでFIRフィルタ - whoopsidaisies's diary</a></p>
</div>
whoopsidaisies
C#ã§Excelãã¡ã¤ã«ãä½æã»ã°ã©ããæ¿å
¥ãããNetOfficeã«ããæ¹æ³
hatenablog://entry/12921228815726400684
2014-06-19T10:10:32+09:00
2014-06-19T10:10:32+09:00 C#ããExcelãã¡ã¤ã«ãä½ã£ã¦ï¼ã°ã©ããæ¿å
¥ãããï¼ä»¥åï¼ä»¥ä¸ã®è¨äºã§ClosedXmlã¨ããã©ã¤ãã©ãªã使ã£ã¦C#ããç°¡åã«Excelãã¡ã¤ã«ãä½ãæ¹æ³ãç´¹ä»ãããï¼ã°ã©ãã®æ¿å
¥ãåºæ¥ãªãã®ãã°ã©ãã®æ¿å
¥ãåºæ¥ãªãã®ãæ°ã«ãªã£ã¦ããï¼ C#ã§Excelãã¡ã¤ã«ãä½æãã ClosedXmlãä½¿ç¨ - whoopsidaisies's diaryNetOfficeã¨ããã©ã¤ãã©ãªã使ãã°ï¼ClosedXmlã¨åããããç°¡åã«Excelãã¡ã¤ã«ãä½æã§ãï¼ããã«ã°ã©ãã®æ¿å
¥ãè¡ããã®ã§ï¼ä»åã¯ãã®æ¹æ³ãç´¹ä»ããï¼ NetOfficeã®ã¤ã³ã¹ãã¼ã« NetOfficeã¯Microsoft Ofâ¦
<p>C#ããExcelãã¡ã¤ã«ãä½ã£ã¦ï¼ã°ã©ããæ¿å
¥ãããï¼</p><p>以åï¼ä»¥ä¸ã®è¨äºã§<a href="https://closedxml.codeplex.com/">ClosedXml</a>ã¨ããã©ã¤ãã©ãªã使ã£ã¦C#ããç°¡åã«Excelãã¡ã¤ã«ãä½ãæ¹æ³ãç´¹ä»ãããï¼ã°ã©ãã®æ¿å
¥ãåºæ¥ãªãã®ãã°ã©ãã®æ¿å
¥ãåºæ¥ãªãã®ãæ°ã«ãªã£ã¦ããï¼<br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2013/11/12/092843"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2013%2F11%2F12%2F092843" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2013/11/12/092843">C#でExcelファイルを作成する ClosedXmlを使用 - whoopsidaisies's diary</a></p><p><a href="http://netoffice.codeplex.com/">NetOffice</a>ã¨ããã©ã¤ãã©ãªã使ãã°ï¼ClosedXmlã¨åããããç°¡åã«Excelãã¡ã¤ã«ãä½æã§ãï¼ããã«ã°ã©ãã®æ¿å
¥ãè¡ããã®ã§ï¼ä»åã¯ãã®æ¹æ³ãç´¹ä»ããï¼</p>
<div class="section">
<h3>NetOfficeã®ã¤ã³ã¹ãã¼ã«</h3>
<p><a href="http://netoffice.codeplex.com/">NetOffice</a>ã¯Microsoft Officeã«ã¢ã¯ã»ã¹ããããã®.NETã®ã©ã¤ãã©ãªã§ï¼ä»åç´¹ä»ããExcel以å¤ã«ãï¼Word, PowerPointçã«ãã¢ã¯ã»ã¹ã§ãããããï¼</p><p>ã¤ã³ã¹ãã¼ã«ã¯Nugetçµç±ã§å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ããæ¤ç´¢ã¦ãNetOffice.Excelããã¤ã³ã¹ãã¼ã«ããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140619/20140619095605.png" alt="f:id:whoopsidaisies:20140619095605p:plain" title="f:id:whoopsidaisies:20140619095605p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>åä½ç¢ºèª</h3>
<p>以ä¸ï¼åä½ç¢ºèªç¨ã®ã½ã¼ã¹ã³ã¼ãã¨çæãããExcelãã¡ã¤ã«ã®ä¸èº«ï¼å®è¡ç°å¢ã§ã¯Excel2010ãã¤ã³ã¹ãã¼ã«æ¸ã¿ï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synType">class</span> Program
{
<span class="synType">static</span> <span class="synType">void</span> Main(<span class="synType">string</span>[] args)
{
<span class="synComment">// Excelãéã</span>
<span class="synStatement">using</span> (var excelApplication = <span class="synStatement">new</span> NetOffice.ExcelApi.Application())
{
<span class="synComment">// ã¯ã¼ã¯ããã¯ã追å </span>
var workBook = excelApplication.Workbooks.Add();
<span class="synComment">// ã¯ã¼ã¯ã·ã¼ããåå¾</span>
var workSheet = (NetOffice.ExcelApi.Worksheet)workBook.Worksheets[<span class="synConstant">1</span>];
<span class="synComment">// ãã¼ã¿ã®å
¥å</span>
workSheet.Cells[<span class="synConstant">1</span>, <span class="synConstant">2</span>].Value = <span class="synConstant">"ãã©ã¦ã¶ã·ã§ã¢"</span>;
workSheet.Cells[<span class="synConstant">2</span>, <span class="synConstant">1</span>].Value = <span class="synConstant">"IE"</span>;
workSheet.Cells[<span class="synConstant">2</span>, <span class="synConstant">2</span>].Value = <span class="synConstant">"52.56%"</span>;
workSheet.Cells[<span class="synConstant">3</span>, <span class="synConstant">1</span>].Value = <span class="synConstant">"Chrome"</span>;
workSheet.Cells[<span class="synConstant">3</span>, <span class="synConstant">2</span>].Value = <span class="synConstant">"24.7%"</span>;
workSheet.Cells[<span class="synConstant">4</span>, <span class="synConstant">1</span>].Value = <span class="synConstant">"Firefox"</span>;
workSheet.Cells[<span class="synConstant">4</span>, <span class="synConstant">2</span>].Value = <span class="synConstant">"12.92%"</span>;
workSheet.Cells[<span class="synConstant">5</span>, <span class="synConstant">1</span>].Value = <span class="synConstant">"ãã®ä»"</span>;
workSheet.Cells[<span class="synConstant">5</span>, <span class="synConstant">2</span>].Value = <span class="synConstant">"=1-B2-B3-B4"</span>;
<span class="synComment">// ã°ã©ããªãã¸ã§ã¯ãã®è¿½å </span>
var chart = ((NetOffice.ExcelApi.ChartObjects)workSheet.ChartObjects()).Add(<span class="synConstant">70</span>, <span class="synConstant">100</span>, <span class="synConstant">375</span>, <span class="synConstant">225</span>);
<span class="synComment">// åã°ã©ãã«è¨å®</span>
chart.Chart.ChartType = NetOffice.ExcelApi.Enums.XlChartType.xlPie;
<span class="synComment">// ãã¼ã¿ç¯å²ãæå®</span>
chart.Chart.SetSourceData(workSheet.Range(<span class="synConstant">"A1:B5"</span>));
<span class="synComment">// ä¿åï¼ç°å¢ã«åããã¦æ¡å¼µåxlsã¨ãã§ã大ä¸å¤«ã¿ããï¼</span>
workBook.SaveAs(<span class="synSpecial">@</span><span class="synConstant">"d:\test.xlsx"</span>);
<span class="synComment">// Excelãçµäºãã</span>
excelApplication.Quit();
}
}
}
</pre><p>åºæ¥ä¸ãã£ãExcelãã¡ã¤ã«ã®ä¸èº«ã¯ãããªæãï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140619/20140619094620.png" alt="f:id:whoopsidaisies:20140619094620p:plain" title="f:id:whoopsidaisies:20140619094620p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>ãã®ä»</h3>
<p>以ä¸ã®ãã¼ã¸ã«ã°ã©ã以å¤ã®ãµã³ãã«ãå¤æ°ããï¼<br />
<a href="http://netoffice.codeplex.com/wikipage?title=Excel_Examples_EN"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fnetoffice.codeplex.com%2Fwikipage%3Ftitle%3DExcel_Examples_EN" alt="" class="http-favicon" /></a><a href="http://netoffice.codeplex.com/wikipage?title=Excel_Examples_EN">NetOffice - MS Office in .NET - Home</a><br />
<a href="http://pro.art55.jp/?eid=1304102"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fpro.art55.jp%2F%3Feid%3D1304102" alt="" class="http-favicon" /></a><a href="http://pro.art55.jp/?eid=1304102">【NetOffice】【Excel】NetOfficeのまとめ | 創造的プログラミングと粘土細工</a>ï¼ãã£ã¡ã¯æ¥æ¬èªï¼</p>
</div>
whoopsidaisies
C#ã§ã°ã©ããæã OxyPlotã®FunctionSeriesã«ããæ¹æ³
hatenablog://entry/12921228815718131111
2014-02-10T12:29:39+09:00
2014-02-10T12:29:39+09:00 .NETãã¬ã¼ã ã¯ã¼ã¯ç¨ã®ã°ã©ãæç»ã©ã¤ãã©ãªã§ããOxyPlotã使ã£ã¦ã°ã©ããæãï¼ ãã®ä¸ã§ãFunctionSeriesã¯ã©ã¹ã使ã£ã¦ä¸ããããé¢æ°ã®ã°ã©ããæãæ¹æ³ãè¨ãï¼OxyPlotã¯Windows Formã¢ããªã±ã¼ã·ã§ã³ã ãã§ãªãï¼WPFï¼Silverlightï¼Windows8çæ§ã
ãªç°å¢ã§ä½¿ããï¼ Chartã³ã³ããã¼ã«ã¨ã®æ¯è¼ Chartã³ã³ããã¼ã«ã«ããã°ã©ãã®æç»æ¹æ³ã¯ä»¥ä¸ã®å¥ã®è¨äºã§ç´¹ä»ãããã¨ããããï¼æ¯è¼ãã¦OxyPlotã®æ¹ãè¯ããªã¨æã£ã¦ããç¹ããããï¼ é¢æ°ã渡ãã¦ãã®ç¯å²ã表示ããã¨ãã楽ï¼ä»åã®è¨äºã®ã¡ã¤ã³ï¼è©³ç´°ã¯å¾è¿°ï¼ãã¨ãã° ã®ã®ç¯å²ã®ã°ã©ããæâ¦
<p>.NETãã¬ã¼ã ã¯ã¼ã¯ç¨ã®ã°ã©ãæç»ã©ã¤ãã©ãªã§ãã<a href="http://oxyplot.codeplex.com/">OxyPlot</a>ã使ã£ã¦ã°ã©ããæãï¼<br />
ãã®ä¸ã§ãFunctionSeriesã¯ã©ã¹ã使ã£ã¦ä¸ããããé¢æ°ã®ã°ã©ããæãæ¹æ³ãè¨ãï¼</p><p>OxyPlotã¯Windows Formã¢ããªã±ã¼ã·ã§ã³ã ãã§ãªãï¼WPFï¼Silverlightï¼Windows8çæ§ã
ãªç°å¢ã§ä½¿ããï¼</p>
<div class="section">
<h3>Chartã³ã³ããã¼ã«ã¨ã®æ¯è¼</h3>
<p>Chartã³ã³ããã¼ã«ã«ããã°ã©ãã®æç»æ¹æ³ã¯ä»¥ä¸ã®<a href="http://whoopsidaisies.hatenablog.com/entry/2013/11/26/030331">別の記事</a>ã§ç´¹ä»ãããã¨ããããï¼æ¯è¼ãã¦OxyPlotã®æ¹ãè¯ããªã¨æã£ã¦ããç¹ããããï¼</p>
<ul>
<li>é¢æ°ã渡ãã¦ãã®ç¯å²ã表示ããã¨ãã楽ï¼ä»åã®è¨äºã®ã¡ã¤ã³ï¼è©³ç´°ã¯å¾è¿°ï¼ãã¨ãã°</li>
</ul><p><img src="http://chart.apis.google.com/chart?cht=tx&chl=y%3Dx%5E3%2B2x%5E2-3" alt="y=x^3+2x^2-3"/>ã®<img src="http://chart.apis.google.com/chart?cht=tx&chl=-2%5Cle%20x%5Cle%202" alt="-2\le x\le 2"/>ã®ç¯å²ã®ã°ã©ããæç»ã¨ãï¼</p>
<ul>
<li>ãã¦ã¹æä½ã«ããã°ã©ãã®æ¡å¤§ã»ç¸®å°ï¼ç§»åçã®æ©è½ãæåããã¤ãã¦ãã</li>
<li>ãã¯ã¿ã¼ç»åã§ãããã«ã°ã©ããä¿åã§ããï¼Chartã³ã³ããã¼ã«ã§ãEMFã§ä¿åã§ãããã°ã©ãã®ç¨®é¡ã«ãã£ã¦ã¯æ±ãï¼</li>
<li>é
åãã¼ã¿çã«ãã¤ã³ãã£ã³ã°ããã¦ï¼è¤æ°ã®ã°ã©ããæç»ããã¨ã便å©ãªæ°ãããï¼ä»åº¦è¨äºã«ã¾ã¨ãããã¨æãã¾ãï¼</li>
</ul>
</div>
<div class="section">
<h3>OxyPlotã®ã¤ã³ã¹ãã¼ã«</h3>
<p>NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããOxyPlotããæ¤ç´¢ï¼èªåã«åã£ãç°å¢ã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ï¼ï¼ãã®è¨äºã§ã¯OxyPlot.WindowsFormsã使ã£ãï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140210/20140210110630.png" alt="f:id:whoopsidaisies:20140210110630p:plain" title="f:id:whoopsidaisies:20140210110630p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>Plotã³ã³ããã¼ã«ã®è¿½å </h3>
<p>ã°ã©ãæç»ç¨ã®Plotã¨ããã³ã³ããã¼ã«ãç¨æããã¦ããã®ã§ä½¿ãï¼</p><p>ãã¼ã«ããã¯ã¹ã®é©å½ãªã¨ããã§å³ã¯ãªãã¯ãã¦ãã¢ã¤ãã ã®é¸æ(I)...ããé¸æï¼ã.NET Framework ã³ã³ãã¼ãã³ããã¿ãã®ãåç
§(B)...ããã¿ã³ãæ¼ãã¦ï¼ã(ã½ãªã¥ã¼ã·ã§ã³ãã©ã«ã)\packages\OxyPlot.WindowsForms.yyyy.x.xxx.x\lib\NET45\OxyPlot.WindowsForms.dllããé¸æãããOKï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><a href="http://f.hatena.ne.jp/whoopsidaisies/20140210111230" class="hatena-fotolife" itemprop="url"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140210/20140210111230.png" alt="f:id:whoopsidaisies:20140210111230p:image:w275" title="f:id:whoopsidaisies:20140210111230p:image:w275" class="hatena-fotolife" style="width:275px" itemprop="image"></a></span> <span itemscope itemtype="http://schema.org/Photograph"><a href="http://f.hatena.ne.jp/whoopsidaisies/20140210111034" class="hatena-fotolife" itemprop="url"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140210/20140210111034.png" alt="f:id:whoopsidaisies:20140210111034p:image:w275" title="f:id:whoopsidaisies:20140210111034p:image:w275" class="hatena-fotolife" style="width:275px" itemprop="image"></a></span></p><p>ããã¨ï¼ãã¼ã«ããã¯ã¹ã«ãPlotããã§ããã®ã§ï¼Formã«é
ç½®ããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140210/20140210111336.png" alt="f:id:whoopsidaisies:20140210111336p:plain" title="f:id:whoopsidaisies:20140210111336p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>FunctionSeries</h3>
<p>OxyPlotã«ã¯ï¼<a href="http://msdn.microsoft.com/ja-jp/library/bb549151(v=vs.110).aspx">Func<double, double></a>ã®ã¡ã½ããã®ã°ã©ããæç»ãã¦ããã<a href="http://www.oxyplot.org/doc/API/OxyPlot.Series.FunctionSeries.html">FunctionSeries</a>ã¯ã©ã¹ãããã®ã§ãã®ä½¿ãæ¹ãè¨ãï¼<br />
Func<double, double>ã¨ããæ¸ãæ¹ã«ãªãã¿ããªã人ããããããããªãã®ã§ï¼ã¨ããããæ¨æºæ£è¦åå¸<br />
<img src="http://chart.apis.google.com/chart?cht=tx&chl=f%5C%28x%5C%29%3D%5Cfrac%7B1%7D%7B%5Csqrt%7B2%5Cpi%7D%7Dexp%5C%28-%5Cfrac%7Bx%5E%7B2%7D%7D%7B2%7D%5C%29" alt="f\(x\)=\frac{1}{\sqrt{2\pi}}exp\(-\frac{x^{2}}{2}\)"/><br />
ãæããµã³ãã«ã以ä¸ã«ç¤ºãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synType">private</span> <span class="synType">static</span> <span class="synType">double</span> StandardNormalDistribution(<span class="synType">double</span> x)
{
<span class="synStatement">return</span> <span class="synConstant">1</span> / Math.Sqrt(<span class="synConstant">2</span> * Math.PI) * Math.Exp(-x * x / <span class="synConstant">2</span>);
}
<span class="synType">private</span> <span class="synType">void</span> Form1_Load(<span class="synType">object</span> sender, EventArgs e)
{
plot1.Model = <span class="synStatement">new</span> OxyPlot.PlotModel { PlotType = OxyPlot.PlotType.XY };
var series = <span class="synStatement">new</span> OxyPlot.Series.FunctionSeries(
StandardNormalDistribution, <span class="synComment">// å¼æ°doubleï¼æ»ãå¤doubleã®é¢æ°</span>
-<span class="synConstant">3</span>, <span class="synComment">// x座æ¨ã®æå°å¤</span>
<span class="synConstant">3</span>, <span class="synComment">// x座æ¨ã®æ大å¤</span>
<span class="synConstant">0.01</span>, <span class="synComment">// x座æ¨ã®å»ã¿å¹
</span>
<span class="synConstant">"æ¨æºæ£è¦åå¸"</span>); <span class="synComment">// ã°ã©ãã¿ã¤ãã«</span>
plot1.Model.Series.Add(series);
}
</pre><p>å®è¡ããã¨ä»¥ä¸ã®ãããªã°ã©ãã表示ãããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140210/20140210114639.png" alt="f:id:whoopsidaisies:20140210114639p:plain" title="f:id:whoopsidaisies:20140210114639p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>StandardNormalDistributionã¨ããå¼æ°ãdoubleåï¼æ»ãå¤ãdoubleåã®é¢æ°ãå®ç¾©ãã¦ããï¼ãããFunc<double, double>ã®ã¡ã½ããã§ããï¼<br />
ããã¨ï¼ã°ã©ãæç»ããããç¯å²ãFunctionSeriesã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ã«æ¸¡ãã¦ããã ãã§ã°ã©ããæç»ãã¦ããã¦é常ã«ä¾¿å©ã§ããï¼</p>
</div>
<div class="section">
<h3>ã©ã ãå¼ã«ããæ¹æ³</h3>
<p>ã¡ã½ããã®é¨åã<a href="http://msdn.microsoft.com/ja-jp/library/bb397687.aspx">ラムダ式</a>ã§è¡¨ç¾ãããã¨ãå½ç¶åºæ¥ãã®ã§ï¼StandardNormalDistributionã¡ã½ãããããããå®ç¾©ããªãã§ã以ä¸ã®ããã«æ¸ããã¨ãã§ããï¼ï¼ããã§ã¯ã©ã ãå¼ã®èª¬æã¯çç¥ï¼ããããªã人ã¯<a href="http://ufcpp.net/study/csharp/sp3_lambda.html">ここらのへんのページ</a>ãåç
§ï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink> var series = <span class="synStatement">new</span> OxyPlot.Series.FunctionSeries(
x => <span class="synConstant">1</span> / Math.Sqrt(<span class="synConstant">2</span> * Math.PI) * Math.Exp(-x * x / <span class="synConstant">2</span>), <span class="synComment">// å¼æ°doubleï¼æ»ãå¤doubleã®é¢æ°</span>
-<span class="synConstant">3</span>, <span class="synComment">// x座æ¨ã®æå°å¤</span>
<span class="synConstant">3</span>, <span class="synComment">// x座æ¨ã®æ大å¤</span>
<span class="synConstant">0.01</span>, <span class="synComment">// x座æ¨ã®å»ã¿å¹
</span>
<span class="synConstant">"æ¨æºæ£è¦åå¸"</span>); <span class="synComment">// ã°ã©ãã¿ã¤ãã«</span>
</pre>
</div>
<div class="section">
<h3>åªä»å¤æ°è¡¨ç¤ºãããé¢æ°ã®ã°ã©ãæç»</h3>
<p>ãããç°¡åã«åºæ¥ãã®ã§ä¾ã示ãï¼ä¾ã¨ãã¦ä»¥ä¸ã®<a href="http://www.phoenix-c.or.jp/~tokioka/Epicycloid/Epicycloid.html">カージオイド</a>ã表示ããã¦ã¿ãï¼<br />
<img src="http://chart.apis.google.com/chart?cht=tx&chl=x%3Da%5C%282%5Ccos%5Ctheta%20-%20%5Ccos2%5Ctheta%5C%29" alt="x=a\(2\cos\theta - \cos2\theta\)"/><br />
<img src="http://chart.apis.google.com/chart?cht=tx&chl=y%3Da%5C%282%5Csin%5Ctheta%20-%20%5Csin2%5Ctheta%5C%29" alt="y=a\(2\sin\theta - \sin2\theta\)"/></p><p>ã½ã¼ã¹ã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãï¼ï¼ã©ã ãå¼ä½¿ç¨ï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>= <span class="synStatement">new</span> OxyPlot.PlotModel { PlotType = OxyPlot.PlotType.XY };
var series = <span class="synStatement">new</span> OxyPlot.Series.FunctionSeries(
t => <span class="synConstant">2</span> * Math.Cos(t) - Math.Cos(<span class="synConstant">2</span> * t), <span class="synComment">// x座æ¨ã®é¢æ°</span>
t => <span class="synConstant">2</span> * Math.Sin(t) - Math.Sin(<span class="synConstant">2</span> * t), <span class="synComment">// y座æ¨ã®é¢æ°</span>
<span class="synConstant">0</span>, <span class="synComment">// tã®æå°å¤</span>
<span class="synConstant">2</span> * Math.PI, <span class="synComment">// tã®æ大å¤</span>
Math.PI / <span class="synConstant">32</span>, <span class="synComment">// tã®å»ã¿å¹
</span>
<span class="synConstant">"ã«ã¼ã¸ãªã¤ã"</span>); <span class="synComment">// ã°ã©ãã¿ã¤ãã«</span>
plot1.Model.Series.Add(series);
</pre><p>å®è¡ããã¨ä»¥ä¸ã®ãããªã°ã©ãã表示ãããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140210/20140210122606.png" alt="f:id:whoopsidaisies:20140210122606p:plain" title="f:id:whoopsidaisies:20140210122606p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>ãã®ä»</h3>
<p>PlotTypeã®è¨å®ã«ãã£ã¦æ¥µåº§æ¨è¡¨ç¤ºã¨ããã§ãããããã¯ã¾ãã®æ©ä¼ã«ï¼</p>
</div>
whoopsidaisies
C#ã§å°çã表示ããï¼vtkTexturedSphereSourceã«ããæ¹æ³ï¼
hatenablog://entry/12921228815718096784
2014-02-09T20:34:07+09:00
2014-02-09T20:34:07+09:00 VTKã®vtkTexturedSphereSourceã§çã«ä¸çå°å³ã®ãã¯ã¹ãã£ãè²¼ãä»ãããã¨ã§å°çã表示ãããï¼ãã¯ã¹ãã£ã使ããã«vtkEarthSourceã«ãã£ã¦è¡¨ç¤ºããæ¹æ³ã¯ä»¥ä¸ã®ãã¼ã¸ãåç
§ï¼ C#ã§å°çã表示ããï¼VTKã®EarthSourceã«ããæ¹æ³ï¼ - whoopsidaisies's diary ActiViz ActiVizã¯ï¼3Dã³ã³ãã¥ã¼ã¿ã°ã©ãã£ãã¯ã¹ã®å¯è¦åã©ã¤ãã©ãªVTKï¼The Visualization ToolKitï¼ã®Cï¼ã©ããã§ããï¼NuGetããã¤ã³ã¹ãã¼ã«ã§ããï¼ç°¡åãªè§£èª¬ã¯ä»¥ä¸ã®ãã¼ã¸ãåç
§ï¼ C#ã§3Dã¢ãã«è¡¨ç¤ºï¼VTKã®C#ã©ããActâ¦
<p>VTKã®vtkTexturedSphereSourceã§çã«ä¸çå°å³ã®ãã¯ã¹ãã£ãè²¼ãä»ãããã¨ã§å°çã表示ãããï¼</p><p>ãã¯ã¹ãã£ã使ããã«vtkEarthSourceã«ãã£ã¦è¡¨ç¤ºããæ¹æ³ã¯ä»¥ä¸ã®ãã¼ã¸ãåç
§ï¼<br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2014/02/09/185536"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2014%2F02%2F09%2F185536" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2014/02/09/185536">C#で地球を表示する(VTKのEarthSourceによる方法) - whoopsidaisies's diary</a><br />
</p>
<div class="section">
<h3>ActiViz</h3>
<p><a href="http://www.kitware.com/opensource/avdownload.php">ActiViz</a>ã¯ï¼3Dã³ã³ãã¥ã¼ã¿ã°ã©ãã£ãã¯ã¹ã®å¯è¦åã©ã¤ãã©ãª<a href="http://www.vtk.org/">VTK(The Visualization ToolKit)</a>ã®Cï¼ã©ããã§ããï¼NuGetããã¤ã³ã¹ãã¼ã«ã§ããï¼ç°¡åãªè§£èª¬ã¯ä»¥ä¸ã®ãã¼ã¸ãåç
§ï¼<br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/28/131053"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2013%2F12%2F28%2F131053" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/28/131053">C#で3Dモデル表示(VTKのC#ラッパActiVizによる方法) - whoopsidaisies's diary</a><br />
</p>
</div>
<div class="section">
<h3>RenderWindowControl</h3>
<p>NuGetããActiVizãã¤ã³ã¹ãã¼ã«ãï¼RenderWindowControlããã©ã¼ã ã«è¿½å ããï¼</p>
</div>
<div class="section">
<h3>vtkTexturedSphereSource</h3>
<p>VTKã«ã¯<a href="http://www.vtk.org/doc/nightly/html/classvtkTexturedSphereSource.html">vtkTexturedSphereSource</a>ã¨ããï¼ãã¯ã¹ãã£ãè²¼ãä»ãããã¨ãåºæ¥ãçãªãã¸ã§ã¯ãã®ã¯ã©ã¹ããããããããå©ç¨ããï¼ã½ã¼ã¹ã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>sing (var sphere = <span class="synStatement">new</span> Kitware.VTK.vtkTexturedSphereSource())
<span class="synStatement">using</span> (var texture = <span class="synStatement">new</span> Kitware.VTK.vtkTexture())
<span class="synStatement">using</span> (var image = <span class="synStatement">new</span> Kitware.VTK.vtkPNGReader())
<span class="synStatement">using</span> (var mapper = <span class="synStatement">new</span> Kitware.VTK.vtkCompositePolyDataMapper())
<span class="synStatement">using</span> (var actor = <span class="synStatement">new</span> Kitware.VTK.vtkActor())
{
<span class="synComment">// çã®æ»ãããï¼æ°åãå¤ãã»ã©åå²æ°ãå¤ãæ»ããã«ãªãï¼</span>
sphere.SetThetaResolution(<span class="synConstant">64</span>);
sphere.SetPhiResolution(<span class="synConstant">64</span>);
mapper.SetInputConnection(sphere.GetOutputPort());
actor.SetMapper(mapper);
<span class="synComment">// ä¸çå°å³ç»åã®èªã¿è¾¼ã¿ã¨ãã¯ã¹ãã£ã®è¨å®</span>
image.SetFileName(<span class="synSpecial">@</span><span class="synConstant">"WorldMap_ja.png"</span>);
texture.SetInputConnection(image.GetOutputPort());
actor.SetTexture(texture);
renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer().AddActor(actor);
}
</pre><p>å®è¡ããã¨ä»¥ä¸ã®ããã«å°çã表示ãããï¼ä¸çå°å³ç»åã¯<a href="http://ja.wikipedia.org/wiki/%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB:WorldMap_ja.png">ウィキペディア</a>ã«ãã£ããã®ã使ã£ãï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140209/20140209202615.png" alt="f:id:whoopsidaisies:20140209202615p:plain" title="f:id:whoopsidaisies:20140209202615p:plain" class="hatena-fotolife" itemprop="image"></span></p><p>以ä¸ã®ããã«æ¡å¤§è¡¨ç¤ºãã§ãããï¼ãã®æ¹æ³ã ã¨ãã¯ã¿ã¼ã°ã©ãã£ãã¯ã®èªã¿è¾¼ã¿ãï¼ãã¶ãï¼ã§ããªãã®ã§æ¡å¤§è¡¨ç¤ºããéã¯ä½ããã工夫ãå¿
è¦ããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140209/20140209203055.png" alt="f:id:whoopsidaisies:20140209203055p:plain" title="f:id:whoopsidaisies:20140209203055p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
whoopsidaisies
C#ã§å°çã表示ããï¼VTKã®EarthSourceã«ããæ¹æ³ï¼
hatenablog://entry/12921228815718088740
2014-02-09T18:55:36+09:00
2014-02-09T18:55:36+09:00 C#ã§VTKã®vtkEarthSourceã¯ã©ã¹ã«ãã£ã¦å°çã表示ãããï¼ ActiViz ActiVizã¯ï¼3Dã³ã³ãã¥ã¼ã¿ã°ã©ãã£ãã¯ã¹ã®å¯è¦åã©ã¤ãã©ãªVTKï¼The Visualization ToolKitï¼ã®Cï¼ã©ããã§ããï¼NuGetããã¤ã³ã¹ãã¼ã«ã§ããï¼ç°¡åãªè§£èª¬ã¯ä»¥ä¸ã®ãã¼ã¸ãåç
§ï¼ C#ã§3Dã¢ãã«è¡¨ç¤ºï¼VTKã®C#ã©ããActiVizã«ããæ¹æ³ï¼ - whoopsidaisies's diary RenderWindowControl NuGetããActiVizãã¤ã³ã¹ãã¼ã«ãï¼RenderWindowControlããã©ã¼ã ã«è¿½å ããï¼ vtkEarthSourceâ¦
<p>C#ã§VTKã®vtkEarthSourceã¯ã©ã¹ã«ãã£ã¦å°çã表示ãããï¼</p>
<div class="section">
<h3>ActiViz</h3>
<p><a href="http://www.kitware.com/opensource/avdownload.php">ActiViz</a>ã¯ï¼3Dã³ã³ãã¥ã¼ã¿ã°ã©ãã£ãã¯ã¹ã®å¯è¦åã©ã¤ãã©ãª<a href="http://www.vtk.org/">VTK(The Visualization ToolKit)</a>ã®Cï¼ã©ããã§ããï¼NuGetããã¤ã³ã¹ãã¼ã«ã§ããï¼ç°¡åãªè§£èª¬ã¯ä»¥ä¸ã®ãã¼ã¸ãåç
§ï¼<br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/28/131053"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2013%2F12%2F28%2F131053" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2013/12/28/131053">C#で3Dモデル表示(VTKのC#ラッパActiVizによる方法) - whoopsidaisies's diary</a><br />
</p>
</div>
<div class="section">
<h3>RenderWindowControl</h3>
<p>NuGetããActiVizãã¤ã³ã¹ãã¼ã«ãï¼RenderWindowControlããã©ã¼ã ã«è¿½å ããï¼</p>
</div>
<div class="section">
<h3>vtkEarthSource</h3>
<p>VTKã«ã¯<a href="http://www.vtk.org/doc/release/5.0/html/a01341.html">vtkEarthSource</a>ã¨ããï¼å°çã表示ããããªãã¸ã§ã¯ããããã®ã§ä½¿ãï¼ã½ã¼ã¹ã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synStatement">using</span> (var earth = <span class="synStatement">new</span> Kitware.VTK.vtkEarthSource())
<span class="synStatement">using</span> (var mapper = <span class="synStatement">new</span> Kitware.VTK.vtkCompositePolyDataMapper())
<span class="synStatement">using</span> (var actor = <span class="synStatement">new</span> Kitware.VTK.vtkActor())
{
mapper.SetInputConnection(earth.GetOutputPort());
actor.SetMapper(mapper);
renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer().AddActor(actor);
}
</pre><p>å®è¡ããã¨ä»¥ä¸ã®ããã«å°çã表示ãããï¼ãã©ãã°ã§è¦ç¹å¤æ´ãåºæ¥ãï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140209/20140209185406.png" alt="f:id:whoopsidaisies:20140209185406p:plain" title="f:id:whoopsidaisies:20140209185406p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
whoopsidaisies
C++ã§LINQã©ã¤ã¯ãªå¦çï¼LINQ for C++ã«ããæ¹æ³ï¼
hatenablog://entry/12921228815716655711
2014-01-17T01:12:13+09:00
2014-01-17T01:12:13+09:00 LINQ for C++ LINQã¯.NET Framework3.5ããçµã¿è¾¼ã¾ããæ©è½ã§ï¼C#çã®è¨èªã§SQLã®ãã¼ã¿ãã¼ã¹æä½ã®ãããªãã¨ãå¯è½ã¨ããï¼ãC# is LINQãã¨è¨ãæ¹ã¾ã§ãã»ã©ã«ä¾¿å©ãªæ©è½ï¼ãããï¼C++/CLIã¯LINQã«å¯¾å¿ããäºå®ã¯ãªãã¨ã®ãã¨ï¼ããã§ï¼LINQã«ä¼¼ãæ©è½ãC++ã«æä¾ãã¦ãããã®ãLINQ for C++ã§ããï¼ã¨ããããã§LINQ for C++ã使ã£ã¦ã¿ãï¼ å°å
¥ LINQ for C++ã¯ããããã¡ã¤ã«ã²ã¨ã¤ã§å®è£
ããã¦ããã®ã§ï¼ä»¥ä¸ã®ãã¼ã¸ãããã¦ã³ãã¼ããã¦ãã¦ã¤ã³ã¯ã«ã¼ãããã ãã§ä½¿ç¨ã§ããï¼NuGetããã®ã¤ã³ã¹ãã¼ã«ãåå¾å¯è½ã§ãâ¦
<div class="section">
<h3>LINQ for C++</h3>
<p><a href="http://ja.wikipedia.org/wiki/%E7%B5%B1%E5%90%88%E8%A8%80%E8%AA%9E%E3%82%AF%E3%82%A8%E3%83%AA">LINQ</a>ã¯.NET Framework3.5ããçµã¿è¾¼ã¾ããæ©è½ã§ï¼C#çã®è¨èªã§SQLã®ãã¼ã¿ãã¼ã¹æä½ã®ãããªãã¨ãå¯è½ã¨ããï¼ã<a href="http://www.slideshare.net/neuecc/the-history-of-linq/19">C# is LINQ</a>ãã¨è¨ãæ¹ã¾ã§ãã»ã©ã«ä¾¿å©ãªæ©è½ï¼</p><p>ãããï¼<a href="http://ja.wikipedia.org/wiki/%E7%B5%B1%E5%90%88%E8%A8%80%E8%AA%9E%E3%82%AF%E3%82%A8%E3%83%AA">C++/CLIはLINQに対応する予定はない</a>ã¨ã®ãã¨ï¼ããã§ï¼LINQã«ä¼¼ãæ©è½ãC++ã«æä¾ãã¦ãããã®ã<a href="http://cpplinq.codeplex.com/">LINQ for C++</a>ã§ããï¼ã¨ããããã§LINQ for C++ã使ã£ã¦ã¿ãï¼</p>
</div>
<div class="section">
<h3>å°å
¥</h3>
<p>LINQ for C++ã¯ããããã¡ã¤ã«ã²ã¨ã¤ã§å®è£
ããã¦ããã®ã§ï¼ä»¥ä¸ã®ãã¼ã¸ãããã¦ã³ãã¼ããã¦ãã¦ã¤ã³ã¯ã«ã¼ãããã ãã§ä½¿ç¨ã§ããï¼NuGetããã®ã¤ã³ã¹ãã¼ã«ãåå¾å¯è½ã§ããï¼</p><p><a href="http://cpplinq.codeplex.com/"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fcpplinq.codeplex.com%2F" alt="" class="http-favicon" /></a><a href="http://cpplinq.codeplex.com/">LINQ for C++ - Home</a><br />
</p>
</div>
<div class="section">
<h3>使ç¨ä¾ï¼</h3>
<p>以ä¸ã«ä½¿ç¨ä¾ã示ãï¼LINQ for C++ã使ã£ã¦ï¼ãã¹ãã®æ績ã®ãã¡å½èªã¨è±èªãã¨ãã«ï¼ï¼ç¹ä»¥ä¸ã®äººã®ãªã¹ããåå¾ãã¦ããï¼</p><p>æ®éã®é
åã«å¯¾ãã¦ä½¿ããã¨ãåºæ¥ãï¼ã³ã¼ãè£å®ãå¾®å¦ã ãï¼åæè¨ããªãã¡ããããªããï¼ã¡ã½ããå½¢å¼ãªããã§C#ã®LINQã»ã©è»½å¿«ã«ã¯æ¸ããªããã®ã®ï¼ä¾¿å©ã§ã¯ããï¼</p>
<pre class="code lang-cpp" data-lang="cpp" data-unlink><span class="synPreProc">#include </span><span class="synConstant"><cpplinq.hpp></span>
<span class="synType">void</span> main()
{
<span class="synStatement">using</span> <span class="synType">namespace</span> cpplinq;
<span class="synType">struct</span> Seiseki
{
<span class="synType">char</span> Name[<span class="synConstant">256</span>];
<span class="synType">int</span> Kokugo;
<span class="synType">int</span> Sansuu;
<span class="synType">int</span> Eigo;
<span class="synType">int</span> Rika;
<span class="synType">int</span> Shakai;
};
Seiseki seisekiList[] =
{
{<span class="synConstant">"Yamada"</span>,<span class="synConstant">98</span>,<span class="synConstant">78</span>,<span class="synConstant">61</span>,<span class="synConstant">83</span>,<span class="synConstant">70</span>},
{<span class="synConstant">"Tanaka"</span>,<span class="synConstant">20</span>,<span class="synConstant">33</span>,<span class="synConstant">16</span>,<span class="synConstant">39</span>,<span class="synConstant">48</span>},
{<span class="synConstant">"Yoshida"</span>,<span class="synConstant">72</span>,<span class="synConstant">65</span>,<span class="synConstant">92</span>,<span class="synConstant">13</span>,<span class="synConstant">26</span>},
{<span class="synConstant">"Suzuki"</span>,<span class="synConstant">49</span>,<span class="synConstant">82</span>,<span class="synConstant">55</span>,<span class="synConstant">11</span>,<span class="synConstant">96</span>},
{<span class="synConstant">"Sasaki"</span>,<span class="synConstant">83</span>,<span class="synConstant">47</span>,<span class="synConstant">61</span>,<span class="synConstant">23</span>,<span class="synConstant">60</span>}
};
<span class="synType">auto</span> result = from_array(seisekiList)
>> where([](Seiseki s) <span class="synError">{</span><span class="synStatement">return</span> s.Kokugo > <span class="synConstant">50</span> && s.Eigo > <span class="synConstant">50</span>;})
>> to_vector();
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < result.size(); ++ i)
printf(<span class="synConstant">"</span><span class="synSpecial">%s</span><span class="synConstant"> : å½èª</span><span class="synSpecial">%d</span><span class="synConstant"> è±èª</span><span class="synSpecial">%d\n</span><span class="synConstant">"</span>, result[i].Name, result[i].Kokugo, result[i].Eigo);
}
</pre><p>çµæã¯ä»¥ä¸ã®ããã«è¡¨ç¤ºãããï¼</p>
<pre class="code" data-lang="" data-unlink>Yamada : å½èª98 è±èª61
Yoshida : å½èª72 è±èª92
Sasaki : å½èª83 è±èª61</pre>
</div>
<div class="section">
<h3>使ç¨ä¾ï¼</h3>
<p>ç¡çããOpenCVã§ä½¿ã£ã¦ã¿ãï¼BRISKã§ç¹å¾´ç¹æ½åºãï¼ãªãªã¨ã³ãã¼ã·ã§ã³ã®åãã«ãã£ã¦è¡¨ç¤ºããéã®è²ãå¤ãã¦ããï¼</p>
<pre class="code lang-cpp" data-lang="cpp" data-unlink><span class="synPreProc">#include </span><span class="synConstant"><opencv2/opencv.hpp></span>
<span class="synPreProc">#include </span><span class="synConstant"><cpplinq.hpp></span>
<span class="synType">void</span> main()
{
<span class="synStatement">using</span> <span class="synType">namespace</span> cpplinq;
<span class="synType">auto</span> image = cv::imread(<span class="synConstant">"Penguins.jpg"</span>);
<span class="synType">auto</span> detector = cv::FeatureDetector::create(<span class="synConstant">"BRISK"</span>);
std::vector<cv::KeyPoint> keyPoints;
detector->detect(image, keyPoints);
<span class="synType">auto</span> key1 = from(keyPoints)
>> where([](cv::KeyPoint k) <span class="synError">{</span> <span class="synStatement">return</span> <span class="synConstant">0</span> <= k.angle && k.angle < <span class="synConstant">90</span>;})
>> to_vector();
<span class="synType">auto</span> key2 = from(keyPoints)
>> where([](cv::KeyPoint k) <span class="synError">{</span> <span class="synStatement">return</span> <span class="synConstant">90</span> <= k.angle && k.angle < <span class="synConstant">180</span>;})
>> to_vector();
<span class="synType">auto</span> key3 = from(keyPoints)
>> where([](cv::KeyPoint k) <span class="synError">{</span> <span class="synStatement">return</span> <span class="synConstant">180</span> <= k.angle && k.angle < <span class="synConstant">270</span>;})
>> to_vector();
<span class="synType">auto</span> key4 = from(keyPoints)
>> where([](cv::KeyPoint k) <span class="synError">{</span> <span class="synStatement">return</span> <span class="synConstant">270</span> <= k.angle && k.angle < <span class="synConstant">360</span>;})
>> to_vector();
cv::drawKeypoints(image, key1, image, cv::Scalar(<span class="synConstant">255</span>,<span class="synConstant">0</span>,<span class="synConstant">0</span>), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
cv::drawKeypoints(image, key2, image, cv::Scalar(<span class="synConstant">0</span>,<span class="synConstant">255</span>,<span class="synConstant">0</span>), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
cv::drawKeypoints(image, key3, image, cv::Scalar(<span class="synConstant">0</span>,<span class="synConstant">0</span>,<span class="synConstant">255</span>), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
cv::drawKeypoints(image, key4, image, cv::Scalar(<span class="synConstant">255</span>,<span class="synConstant">255</span>,<span class="synConstant">0</span>), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
cv::imshow(<span class="synConstant">"Key Point"</span>, image);
<span class="synStatement">while</span>(cv::waitKey(<span class="synConstant">1</span>) == -<span class="synConstant">1</span>);
}
</pre><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140117/20140117010914.png" alt="f:id:whoopsidaisies:20140117010914p:plain" title="f:id:whoopsidaisies:20140117010914p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
whoopsidaisies
C# ååä»ãã®è²ä¸è¦§ãé
åã«åå¾ãã¦RGBå¤ãDataGridViewã«è¡¨ç¤ºãã
hatenablog://entry/12921228815716589098
2014-01-15T20:24:29+09:00
2014-01-15T20:24:29+09:00 Coloræ§é ä½ .NET Frameworkã®Coloræ§é ä½ã¯RGBå¤ã§è²ã®æå®ãã§ãããï¼ãããããRGBå¤ãæå®ããã¦ãã¦ååãæå®ãã¦ä½¿ããè²ãããï¼ãColor.Redãã¨ããColor.Greenãã¨ãã£ãæãã§ä½¿ããã¨ãåºæ¥ãï¼æ¬è¨äºã§ã¯ï¼ååãä»ããè²ã®ä¸è¦§ãåå¾ãã¦Coloræ§é ä½ã®é
åã«åå¾ï¼ããã«RGBå¤ã¨è²ãDataGridViewã«è¡¨ç¤ºããæ¹æ³ãç´¹ä»ããï¼ ååä»ãã®è²ã®åå¾ ååä»ãã®è²ã¯ï¼Coloræ§é ä½ã®éçããããã£ã¨ãã¦å®ç¾©ããã¦ããï¼è²ã®ä¸è¦§ãColoræ§é ä½ã®é
åã«æ ¼ç´ããã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãï¼ var colors = typeof(Color)â¦
<div class="section">
<h3>Coloræ§é ä½</h3>
<p>.NET Frameworkã®<a href="http://msdn.microsoft.com/ja-jp/library/system.drawing.color(v=vs.110).aspx">Color構造体</a>ã¯RGBå¤ã§è²ã®æå®ãã§ãããï¼ãããããRGBå¤ãæå®ããã¦ãã¦ååãæå®ãã¦ä½¿ããè²ãããï¼ãColor.Redãã¨ããColor.Greenãã¨ãã£ãæãã§ä½¿ããã¨ãåºæ¥ãï¼</p><p>æ¬è¨äºã§ã¯ï¼ååãä»ããè²ã®ä¸è¦§ãåå¾ãã¦Coloræ§é ä½ã®é
åã«åå¾ï¼ããã«RGBå¤ã¨è²ãDataGridViewã«è¡¨ç¤ºããæ¹æ³ãç´¹ä»ããï¼</p>
</div>
<div class="section">
<h3>ååä»ãã®è²ã®åå¾</h3>
<p>ååä»ãã®è²ã¯ï¼Coloræ§é ä½ã®éçããããã£ã¨ãã¦å®ç¾©ããã¦ããï¼è²ã®ä¸è¦§ãColoræ§é ä½ã®é
åã«æ ¼ç´ããã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>var colors = <span class="synStatement">typeof</span>(Color).GetProperties(BindingFlags.Static | BindingFlags.Public)
.Select(p => Color.FromName(p.Name))
.ToList();
</pre><p>ï¼è¡ç®ã§ã¯ï¼<a href="http://msdn.microsoft.com/ja-jp/library/kyaxdd3x(v=vs.110).aspx">GetProperties</a>ã¡ã½ããã使ã£ã¦ï¼Coloræ§é ä½ã®ãããªãã¯ãªéçããããã£ã®åæ
å ±ã®ä¸è¦§ãåå¾ãã¦ããï¼<a href="http://msdn.microsoft.com/ja-jp/library/system.reflection.bindingflags(v=vs.110).aspx">BindingFlags</a>æ§é ä½ã使ã£ã¦åå¾ããããããã£ã®æ¤ç´¢æ¹æ³ãæå®ã§ãããï¼Staticã¨Publicãæå®ãããã¨ã§ãããªãã¯ãªéçããããã£ãåå¾ãã¦ããï¼</p><p>ï¼è¡ç®ã§ã¯ï¼<a href="http://ufcpp.net/study/csharp/sp3_linq.html">LINQ</a>ã®<a href="http://msdn.microsoft.com/ja-jp/library/bb548891(v=vs.110).aspx">Select</a>ã¡ã½ããã¨<a href="http://msdn.microsoft.com/ja-jp/library/system.drawing.color.fromname(v=vs.110).aspx:Color.FromaName">http://msdn.microsoft.com/ja-jp/library/system.drawing.color.fromname(v=vs.110).aspx:Color.FromaName</a>ã¡ã½ããã使ã£ã¦è²ã®ååããï¼ãã®è²ã®Colorãªãã¸ã§ã¯ããçæãã¦ããï¼</p><p>ï¼è¡ç®ã§ï¼çµæãList<Color>ã«å¤æãã¦ããï¼ï¼Listã¨ãArrayã¨ãã«å¤æããã»ããå¾ã®å¦çã楽ãªã®ã§ï¼</p>
</div>
<div class="section">
<h3>DataGridViewã§è¡¨ç¤º</h3>
<p>åå¾ããè²ã®ä¸è¦§ã<a href="http://msdn.microsoft.com/ja-jp/library/system.windows.forms.datagridview(v=vs.110).aspx">DataGridView</a>ã³ã³ããã¼ã«ã«è¡¨ç¤ºããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>dataGridView1.DataSource = colors;
</pre><p>ä¸è¨ã®ä¸è¡ã追å ããã¨ä»¥ä¸ã®ããã«è²ã®ååã¨RGBå¤ã表示ãããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140115/20140115195242.png" alt="f:id:whoopsidaisies:20140115195242p:plain" title="f:id:whoopsidaisies:20140115195242p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>表示ããããããã£ã®é¸æ</h3>
<p>ä¸ã®ç»åã ã¨ãIsKnownColorãã¨ãã®ä½è¨ãªããããã£ã表示ããã¦ããã®ã§ï¼è¡¨ç¤ºããªãããã«ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synStatement">foreach</span> (DataGridViewColumn col <span class="synStatement">in</span> dataGridView1.Columns)
<span class="synStatement">if</span> (col.Name != <span class="synConstant">"R"</span> && col.Name != <span class="synConstant">"G"</span> && col.Name != <span class="synConstant">"B"</span> && col.Name != <span class="synConstant">"Name"</span>)
col.Visible = <span class="synConstant">false</span>;
</pre><p>DataGridViewã®ååã¯<a href="http://msdn.microsoft.com/ja-jp/library/system.windows.forms.datagridviewcolumn.visible(v=vs.110).aspx">Visible</a>ããããã£ã«ãã£ã¦è¡¨ç¤ºã»é表示ãåãæ¿ããããã®ã§ï¼RGBã¨åå以å¤ã®åãé表示ã«è¨å®ãã¦ããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140115/20140115200155.png" alt="f:id:whoopsidaisies:20140115200155p:plain" title="f:id:whoopsidaisies:20140115200155p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>ã»ã«ã®è²ä»ã</h3>
<p>ååã¨RGBå¤ã ãã ã¨ã©ããªè²ãæ³åãã¤ãã«ããã®ã§ï¼ã»ã«ã«è²ãä»ããï¼ã¤ãã§ã«ååã表示ããã¦ããåãå
é ã«ããï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < colors.Count; ++i)
dataGridView1[<span class="synConstant">"Name"</span>, i].Style.BackColor = colors[i];
dataGridView1.Columns[<span class="synConstant">"Name"</span>].DisplayIndex = <span class="synConstant">0</span>;
</pre><p>DataGridViewã®å<a href="http://msdn.microsoft.com/ja-jp/library/system.windows.forms.datagridviewcell(v=vs.110).aspx">セル</a>ã¯<a href="http://msdn.microsoft.com/ja-jp/library/system.windows.forms.datagridviewcell.style(v=vs.110).aspx">Style</a>ããããã£ã«ãã£ã¦<a href="http://msdn.microsoft.com/ja-jp/library/system.windows.forms.datagridviewcellstyle(v=vs.110).aspx">色やフォント等の書式</a>ãæå®åºæ¥ãï¼ããã§ã¯<a href="http://msdn.microsoft.com/ja-jp/library/system.windows.forms.datagridviewcellstyle.backcolor(v=vs.110).aspx">BackColor</a>ããããã£ã«ãã£ã¦èæ¯è²ãæå®ãã¦ããï¼</p><p>ã¾ãï¼<a href="http://msdn.microsoft.com/ja-jp/library/system.windows.forms.datagridviewcolumn.displayindex(v=vs.110).aspx">DisplayIndex</a>ããããã£ã«ãã£ã¦ååã®è¡¨ç¤ºåãå
é ã«ãã¦ããï¼</p><p>å®è¡ããã¨ä»¥ä¸ã®ããã«ååã®ã»ã«ã«è²ãã¤ãã¦è¡¨ç¤ºãããï¼ï¼Transparentã®ã¨ããã¯å¾ãã®ã¦ã£ã³ãã¦ã表示ããã¦ããï¼ï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140115/20140115201854.png" alt="f:id:whoopsidaisies:20140115201854p:plain" title="f:id:whoopsidaisies:20140115201854p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>ã½ã¼ã¹ã³ã¼ã</h3>
<p>ä¸è¨ã³ã¼ããã¾ã¨ããã¨ä»¥ä¸ã®ããã«ãªãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>var colors = <span class="synStatement">typeof</span>(Color).GetProperties(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public)
.Select(p => Color.FromName(p.Name))
.ToList();
dataGridView1.DataSource = colors;
<span class="synStatement">foreach</span> (DataGridViewColumn col <span class="synStatement">in</span> dataGridView1.Columns)
<span class="synStatement">if</span> (col.Name != <span class="synConstant">"R"</span> && col.Name != <span class="synConstant">"G"</span> && col.Name != <span class="synConstant">"B"</span> && col.Name != <span class="synConstant">"Name"</span>)
col.Visible = <span class="synConstant">false</span>;
<span class="synStatement">for</span> (<span class="synType">int</span> i = <span class="synConstant">0</span>; i < colors.Count; ++i)
dataGridView1[<span class="synConstant">"Name"</span>, i].Style.BackColor = colors[i];
dataGridView1.Columns[<span class="synConstant">"Name"</span>].DisplayIndex = <span class="synConstant">0</span>;
</pre>
</div>
whoopsidaisies
C#ã§OpenCVã使ãï¼C++/CLIã«ããæ¹æ³ï¼
hatenablog://entry/12921228815716339920
2014-01-12T11:30:50+09:00
2014-01-12T11:30:50+09:00 OpenCVã©ããã¯ã©ã¹ C#ã§OpenCVãæ軽ã«ä½¿ãã«ã¯OpenCvSharpãã¤ãã ãã®17(NuGetã§å°å
¥) - schima.hatenablog.com C#ã§OpenCVãåããï½NuGetã§OpenCV.Netãã¤ã³ã¹ãã¼ã« - whoopsidaisies's diaryã®ãã¼ã¸ã®ããã«ï¼NuGetããC#ã©ãããã¤ã³ã¹ãã¼ã«ãã¦ä½¿ãæ¹æ³ããããï¼å¿
è¦ãªæ©è½ãã©ããã³ã°ããã¦ããªããã¨ãããï¼ãã®ãã¼ã¸ã§ã¯ï¼C++/CLIã§OpenCVã®å¿
è¦ãªæ©è½ã ãæã¤ã©ããã¯ã©ã¹ãèªåã§ä½ãï¼C#ããå¼ã³åºãæ¹æ³ãç´¹ä»ããï¼ C++/CLI é常ã®C++ã®ã©ã¤ãã©ãªãC#ããå¼ã³åºãâ¦
<div class="section">
<h3>OpenCVã©ããã¯ã©ã¹</h3>
<p>C#ã§OpenCVãæ軽ã«ä½¿ãã«ã¯</p><p><a href="http://schima.hatenablog.com/entry/2013/12/15/110513"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fschima.hatenablog.com%2Fentry%2F2013%2F12%2F15%2F110513" alt="" class="http-favicon" /></a><a href="http://schima.hatenablog.com/entry/2013/12/15/110513">OpenCvSharpをつかう その17(NuGetで導入) - schima.hatenablog.com</a><br />
<a href="http://whoopsidaisies.hatenablog.com/entry/2013/10/25/005953"><img src="http://cdn-ak.favicon.st-hatena.com/?url=http%3A%2F%2Fwhoopsidaisies.hatenablog.com%2Fentry%2F2013%2F10%2F25%2F005953" alt="" class="http-favicon" /></a><a href="http://whoopsidaisies.hatenablog.com/entry/2013/10/25/005953">C#でOpenCVを動かす~NuGetでOpenCV.Netをインストール - whoopsidaisies's diary</a></p><p>ã®ãã¼ã¸ã®ããã«ï¼NuGetããC#ã©ãããã¤ã³ã¹ãã¼ã«ãã¦ä½¿ãæ¹æ³ããããï¼å¿
è¦ãªæ©è½ãã©ããã³ã°ããã¦ããªããã¨ãããï¼</p><p>ãã®ãã¼ã¸ã§ã¯ï¼C++/CLIã§OpenCVã®å¿
è¦ãªæ©è½ã ãæã¤ã©ããã¯ã©ã¹ãèªåã§ä½ãï¼C#ããå¼ã³åºãæ¹æ³ãç´¹ä»ããï¼</p>
</div>
<div class="section">
<h3>C++/CLI</h3>
<p>é常ã®C++ã®ã©ã¤ãã©ãªãC#ããå¼ã³åºããã¨ããã¨DllImportå±æ§ã§å®£è¨ãå¿
è¦ã ã£ãããã¦é¢åã§ãããï¼<a href="http://ja.wikipedia.org/wiki/C%2B%2B/CLI">C++/CLI</a>ã§ä½ã£ãDLLã§ããã°åç
§ã«è¿½å ããã ãã§ä½¿ç¨ã§ããï¼</p>
</div>
<div class="section">
<h3>æé </h3>
<p>æé ã¯ä»¥ä¸ã®éãã§ããï¼</p>
<div class="section">
<h5>C#ããã¸ã§ã¯ãä½æ</h5>
<p>å®è¡ãããC#ã®ããã¸ã§ã¯ã</p>
</div>
<div class="section">
<h5>C++/CLIã®DLLç¨ããã¸ã§ã¯ãä½æ</h5>
<p>OpenCVãã©ããããã¯ã©ã¹ç¨ã®ããã¸ã§ã¯ã</p>
</div>
<div class="section">
<h5>ããã¸ã§ã¯ãã®åç
§ã®è¨å®</h5>
<p>ä½æããã¯ã©ã¹ãCï¼ããèªã¿è¾¼ãããã®è¨å®</p>
</div>
<div class="section">
<h5>OpenCVã®ã¤ã³ã¹ãã¼ã«</h5>
<p>OpenCVã®ã¤ã³ã¹ãã¼ã«</p>
</div>
<div class="section">
<h5>C++/CLIã§ã©ããã¯ã©ã¹ã®ä½æ</h5>
<p>OpenCVã«ããå¦çé¨åã®å®è£
</p>
</div>
<div class="section">
<h5>C#ã®ããã¸ã§ã¯ãã®åºåãã¹ã®å¤æ´</h5>
<p>OpenCVã®DLLã®å ´æã¨ãã®é¢ä¿ä¸ã®è¨å®</p>
</div>
<div class="section">
<h5>C#ããå¼ã³åºã</h5>
<p>C#ããã®å¼ã³åºãé¨åã¨GUIã®å®è£
</p><br />
<p>以ä¸ã«åæé ã®è©³ç´°ãè¨ãï¼</p>
</div>
</div>
<div class="section">
<h3>C#ããã¸ã§ã¯ãä½æ</h3>
<p>Visual Studioã§æ°ããããã¸ã§ã¯ããä½æããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140112/20140112101313.png" alt="f:id:whoopsidaisies:20140112101313p:plain" title="f:id:whoopsidaisies:20140112101313p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
<div class="section">
<h3>C++/CLIã®DLLç¨ããã¸ã§ã¯ãä½æ</h3>
<p>ã½ãªã¥ã¼ã·ã§ã³ãå³ã¯ãªãã¯ãã¦ï¼ã追å ãã®ãæ°ããããã¸ã§ã¯ã(N)...ãã§C++/CLIã®DLLä½æç¨ã®ããã¸ã§ã¯ããä½æããï¼ãVisual C++ãã®ãCLRãã®ãã¯ã©ã¹ ã©ã¤ãã©ãªããé¸æï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140112/20140112101334.png" alt="f:id:whoopsidaisies:20140112101334p:plain" title="f:id:whoopsidaisies:20140112101334p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
<div class="section">
<h3>ããã¸ã§ã¯ãã®åç
§ã®è¨å®</h3>
<p>C++/CLIã§ä½æããDLLãC#ããå¼ã³åºãããã®åç
§è¨å®ãè¡ãï¼C#ã®ããã¸ã§ã¯ãå
ã®ãåç
§è¨å®ããå³ã¯ãªãã¯ããåç
§ã®è¿½å (R)...ããé¸æããï¼éãããã¤ã¢ãã°ã§ãã½ãªã¥ã¼ã·ã§ã³ãã®ãããã¸ã§ã¯ãããé¸æãï¼C++/CLIã®ããã¸ã§ã¯ãã®ååã®ã¨ããã«ãã§ãã¯ãå
¥ããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140112/20140112101620.png" alt="f:id:whoopsidaisies:20140112101620p:plain" title="f:id:whoopsidaisies:20140112101620p:plain" class="hatena-fotolife" itemprop="image"></span><br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140112/20140112102324.png" alt="f:id:whoopsidaisies:20140112102324p:plain" title="f:id:whoopsidaisies:20140112102324p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
<div class="section">
<h3>OpenCVã®ã¤ã³ã¹ãã¼ã«</h3>
<p>C++/CLIã®ããã¸ã§ã¯ããå³ã¯ãªãã¯ããNuGet ããã±ã¼ã¸ã®ç®¡çããé¸æï¼ãã¤ã¢ãã°ã§ããªã³ã©ã¤ã³ããé¸æãï¼æ¤ç´¢çªã§ãOpenCVããæ¤ç´¢ï¼ã¤ã³ã¹ãã¼ã«ããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140112/20140112101806.png" alt="f:id:whoopsidaisies:20140112101806p:plain" title="f:id:whoopsidaisies:20140112101806p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
<div class="section">
<h3>C#ã®ããã¸ã§ã¯ãã®åºåãã¹ã®å¤æ´</h3>
<p>NuGetã§ã¤ã³ã¹ãã¼ã«ããOpenCVã®DLLãï¼C#ããã¸ã§ã¯ãã§ä½æããå®è¡ãã¡ã¤ã«ããåç
§ã§ããä½ç½®ã«é
ç½®ãããªãããï¼å®è¡ãã¡ã¤ã«ã®åºåãã¹ãå¤ãã¦ããï¼C#ã®ããã¸ã§ã¯ããå³ã¯ãªãã¯ããããããã£(R)ããé¸æï¼ããã«ããã®ãåºåãã¹ããã..\Debug\ãã«å¤ããï¼Releaseã¢ã¼ããªã..\Release\ï¼ï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140112/20140112110351.png" alt="f:id:whoopsidaisies:20140112110351p:plain" title="f:id:whoopsidaisies:20140112110351p:plain" class="hatena-fotolife" itemprop="image"></span><br />
ãã®æé ãå¿ããã¨ï¼å®è¡æã«ä»¥ä¸ã®ãããªã¨ã©ã¼ã¡ãã»ã¼ã¸ã表示ããã¦OpenCVã®å¼ã³åºãã«å¤±æããï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140112/20140112110400.png" alt="f:id:whoopsidaisies:20140112110400p:plain" title="f:id:whoopsidaisies:20140112110400p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
<div class="section">
<h3>C++/CLIã§ã©ããã¯ã©ã¹ã®ä½æ</h3>
<p>C++/CLIã§OpenCVã®å¦çã®ã³ã¼ããæ¸ãï¼C++/CLIã®ããã¸ã§ã¯ããä½æããã¨ãã«è²ã
ã¨ãã¡ã¤ã«ãçæããã¦ããã®ã§ï¼ãã®ãã¡ã®ãOpenCvClrLibrary.hãï¼ããã¸ã§ã¯ãå.hï¼ã以ä¸ã®ããã«ããï¼ç»åããã¡ã¤ã«ããèªã¿è¾¼ãã§ï¼BRISKç¹å¾´ç¹ãæ½åºãã¦è¡¨ç¤ºãããµã³ãã«ã§ããï¼</p>
<pre class="code lang-cpp" data-lang="cpp" data-unlink><span class="synComment">// OpenCvClrLibrary.h</span>
<span class="synPreProc">#pragma once</span>
<span class="synPreProc">#include </span><span class="synConstant"><opencv2/opencv.hpp></span>
<span class="synStatement">using</span> <span class="synType">namespace</span> System;
<span class="synType">namespace</span> OpenCvClrLibrary {
<span class="synStatement">public</span> ref <span class="synType">class</span> TestClass
{
<span class="synStatement">public</span>:
<span class="synType">static</span> <span class="synType">void</span> TestMethod()
{
<span class="synType">auto</span> image = cv::imread(<span class="synConstant">"Penguins.jpg"</span>);
<span class="synType">auto</span> brisk = cv::BRISK();
std::vector<cv::KeyPoint> keyPoint;
brisk.detect(image, keyPoint);
cv::drawKeypoints(image, keyPoint, image);
cv::imshow(<span class="synConstant">"image"</span>, image);
<span class="synStatement">while</span> (cv::waitKey(<span class="synConstant">1</span>) == -<span class="synConstant">1</span>);
cv::destroyAllWindows();
}
};
}
</pre><p>ãref classãã¯C++/CLIç¨ã®ã¯ã©ã¹ï¼è©³ç´°ã¯çç¥ãããï¼ããããæ¸ãæ¹ããããã¨ã§C#ã§ãã®ã¾ã¾ä½¿ããã¯ã©ã¹ãä½ããï¼<br />
ãautoãã¯c++11ãã追å ãããæ©è½ã§ï¼å¤æ°ã®åæå¤ããåæ¨è«ãè¡ã£ã¦ãããï¼Visual Studio 2012以éã§ã¯ä½¿ããã¿ããï¼æ¨ªã«é·ããªããã¡ãªOpenCVï¼ã«éããªããã©ï¼ã®ã³ã¼ãã§ã¯ããã使ããã®ã¯å¬ããï¼</p>
</div>
<div class="section">
<h3>C#ããå¼ã³åºã</h3>
<p>C#ããä¸è¨ã®ç¹å¾´ç¹æ½åºå¦çãå¼ã³åºãã³ã¼ãã以ä¸ã®ããã«æ¸ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink><span class="synStatement">using</span> System;
<span class="synStatement">using</span> System.Windows.Forms;
<span class="synType">namespace</span> OpenCvFromCSharp
{
<span class="synType">public</span> <span class="synStatement">partial</span> <span class="synType">class</span> Form1 : Form
{
<span class="synType">public</span> Form1()
{
InitializeComponent();
}
<span class="synType">private</span> <span class="synType">void</span> button1_Click(<span class="synType">object</span> sender, EventArgs e)
{
OpenCvClrLibrary.TestClass.TestMethod();
}
}
}
</pre><p>Buttonã³ã³ããã¼ã«ãé
ç½®ãã¦ï¼ã¯ãªãã¯ããã¨ç¹å¾´ç¹ãæ¸ãè¾¼ã¾ããç»åã以ä¸ã®ããã«è¡¨ç¤ºãããï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140112/20140112104341.png" alt="f:id:whoopsidaisies:20140112104341p:plain" title="f:id:whoopsidaisies:20140112104341p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
whoopsidaisies
C#ã§AIï¼PSDï¼EPSï¼SVGï¼PDFçã®ç»åãã¡ã¤ã«ãéãï¼ImageMagickã®C#ã©ããMagick.NETã«ããæ¹æ³ï¼
hatenablog://entry/12921228815716075117
2014-01-08T21:32:52+09:00
2014-01-08T21:32:53+09:00 Magick.NET 100種é¡ä»¥ä¸ã®ç»åãæä½ããã表示ãããã§ããã©ã¤ãã©ãªImageMagickã®C#ã©ããMagick.NETã使ã£ã¦ï¼C#ã§AIï¼PSDï¼EPSï¼SVGï¼PDFçã®ç»åãã¡ã¤ã«ãéãï¼ ã¤ã³ã¹ãã¼ã« NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããMagick.NETããæ¤ç´¢ãã¦ã¤ã³ã¹ãã¼ã«ï¼ ãã©ãããã©ã¼ã ãå¤ãã ããã¸ã§ã¯ãã®ãã©ãããã©ã¼ã ãã¤ã³ã¹ãã¼ã«ããããã±ã¼ã¸ï¼ãx64ãããx86ãï¼ã«å¤ããï¼ãAny CPUãã ã¨åããªãå ´åãããã®ã§æ³¨æï¼ ãµã³ãã«ã³ã¼ã 以ä¸ã«epsãã¡ã¤â¦
<div class="section">
<h3>Magick.NET</h3>
<p>100種é¡ä»¥ä¸ã®ç»åãæä½ããã表示ãããã§ããã©ã¤ãã©ãª<a href="http://www.imagemagick.org/script/index.php">ImageMagick</a>ã®C#ã©ãã<a href="https://magick.codeplex.com/">Magick.NET</a>ã使ã£ã¦ï¼C#ã§AIï¼PSDï¼EPSï¼SVGï¼PDFçã®ç»åãã¡ã¤ã«ãéãï¼</p>
</div>
<div class="section">
<h3>ã¤ã³ã¹ãã¼ã«</h3>
<p>NuGetçµç±ã§ã¤ã³ã¹ãã¼ã«å¯è½ï¼ããã¸ã§ã¯ããå³ã¯ãªãã¯ãã¦ãNuGetããã±ã¼ã¸ã®ç®¡çããé¸æããï¼ãªã³ã©ã¤ã³ãããMagick.NETããæ¤ç´¢ãã¦ã¤ã³ã¹ãã¼ã«ï¼</p><p><span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140108/20140108210712.png" alt="f:id:whoopsidaisies:20140108210712p:plain" title="f:id:whoopsidaisies:20140108210712p:plain" class="hatena-fotolife" itemprop="image"></span><br />
</p>
</div>
<div class="section">
<h3>ãã©ãããã©ã¼ã ãå¤ãã</h3>
<p>ããã¸ã§ã¯ãã®ãã©ãããã©ã¼ã ãã¤ã³ã¹ãã¼ã«ããããã±ã¼ã¸ï¼ãx64ãããx86ãï¼ã«å¤ããï¼ãAny CPUãã ã¨åããªãå ´åãããã®ã§æ³¨æï¼</p>
</div>
<div class="section">
<h3>ãµã³ãã«ã³ã¼ã</h3>
<p>以ä¸ã«epsãã¡ã¤ã«ãéãã¦ï¼PictureBoxã«è¡¨ç¤ºãããµã³ãã«ã示ãï¼ãã¡ã¤ã«åã®é¨åãå¤ããã°ï¼eps以å¤ã®ãã¡ã¤ã«ãèªã¿è¾¼ããã¨ãåºæ¥ãï¼</p>
<pre class="code lang-cs" data-lang="cs" data-unlink>var magickImage = <span class="synStatement">new</span> ImageMagick.MagickImage(
<span class="synSpecial">@</span><span class="synConstant">"blossom tree.eps"</span>,
<span class="synStatement">new</span> ImageMagick.MagickReadSettings() { Density = <span class="synStatement">new</span> ImageMagick.MagickGeometry(<span class="synConstant">300</span>, <span class="synConstant">300</span>) });
pictureBox1.Image = magickImage.ToBitmap();
</pre><p>ImageMagick.MagickGeometry(300, 300)ã®æ°åã®é¨åã大ããããã¨ï¼AIï¼EPSï¼PDFçã®ãã¯ã¿ã¼ç»åã®èªã¿è¾¼ã¿å¾ã®è§£å度ãé«ããããã¨ãåºæ¥ãï¼</p><p>以ä¸ã®ããã«ï¼ãã¯ã¿ã¼ç»åãé«è§£å度ã«ããã¨æ¡å¤§ãã¦ããããã«è¡¨ç¤ºåºæ¥ãï¼<br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140108/20140108211811.jpg" alt="f:id:whoopsidaisies:20140108211811j:plain" title="f:id:whoopsidaisies:20140108211811j:plain" class="hatena-fotolife" itemprop="image"></span><br />
<span itemscope itemtype="http://schema.org/Photograph"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/w/whoopsidaisies/20140108/20140108211819.png" alt="f:id:whoopsidaisies:20140108211819p:plain" title="f:id:whoopsidaisies:20140108211819p:plain" class="hatena-fotolife" itemprop="image"></span></p>
</div>
whoopsidaisies