{"id":1652,"date":"2008-06-22T18:17:00","date_gmt":"2008-06-22T09:17:00","guid":{"rendered":"http:\/\/r-dimension.xsrv.jp\/classes_j\/?p=1652"},"modified":"2011-05-03T02:07:05","modified_gmt":"2011-05-02T17:07:05","slug":"edge_bubbles","status":"publish","type":"post","link":"https:\/\/r-dimension.xsrv.jp\/classes_j\/edge_bubbles\/","title":{"rendered":"\u30a8\u30c3\u30b8\u306e\u691c\u51fa"},"content":{"rendered":"<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8f2a\u90ed\u3092\u691c\u51fa\u3059\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<pre lang=\"java\" line=\"1\">\r\n\/\/This code has been arranged by Yasushi Noguchi. Last updated on June 21, 2008.\r\n\/\/=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\r\n\/\/BlobDetection by v3ga <http :\/\/processing.v3ga.net>\r\n\/\/May 2005\r\n\/\/Processing(Beta) v0.85\r\n\/\/=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\r\n\r\nimport processing.video.*;\r\nimport blobDetection.*;\r\n\r\nCapture cam;    \/\/Capture\u578b\u5909\u6570\r\nBlobDetection theBlobDetection;    \/\/BlobDetection\u578b\u5909\u6570\r\nPImage img;    \/\/\u7269\u4f53\u306e\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0\u306e\u305f\u3081\u306b\u4f7f\u308f\u308c\u308b\u753b\u50cf\r\nboolean newFrame=false;\r\n\r\n\/\/ ==================================================\r\n\/\/ setup()\r\n\/\/ ==================================================\r\nvoid setup(){\r\n  \/\/\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u30b5\u30a4\u30ba\r\n  size(640, 480);\r\n  \/\/\u30ad\u30e3\u30d7\u30c1\u30e3\u578b\u5909\u6570\u306ecam\u3092\u5ba3\u8a00\r\n  cam = new Capture(this, 320, 240, 30);\r\n  \r\n  \/\/ BlobDetection\r\n  \/\/img\u306f\u30ad\u30e3\u30d7\u30c1\u30e3\u6620\u50cf\u3088\u308a\u3082\u5c0f\u3055\u304f\u3067\u304d\u308b\r\n  img = new PImage(80,60); \r\n  \/\/\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0\u3092\u958b\u59cb\r\n  theBlobDetection = new BlobDetection(img.width, img.height);\r\n  \/\/\u6697\u3044\u5834\u6240\u3092\u63a2\u3059\u306b\u306ffalse, \u660e\u308b\u3044\u5834\u6240\u306ftrue\u306b\u3059\u308b\r\n  theBlobDetection.setPosDiscrimination(false);\r\n  theBlobDetection.setThreshold(0.5f); \/\/\u3057\u304d\u3044\u5024\u306e\u8a2d\u5b9a\r\n}\r\n\r\n\/\/ ==================================================\r\n\/\/ captureEvent()\r\n\/\/ ==================================================\r\nvoid captureEvent(Capture cam){\r\n  cam.read();    \/\/\u30ab\u30e1\u30e9\u304b\u3089\u6620\u50cf\u3092\u5e38\u306b\u53d6\u308a\u8fbc\u3080\r\n  newFrame = true;\r\n}\r\n\r\n\/\/ ==================================================\r\n\/\/ draw()\r\n\/\/ ==================================================\r\nvoid draw(){\r\n\r\n  if (newFrame){    \/\/\u65b0\u3057\u3044\u30d5\u30ec\u30fc\u30e0\u304c\u3042\u3063\u305f\u3089\u3001\r\n    background(255);\r\n    newFrame=false;\r\n    image(cam,0,0,width,height);    \/\/\u753b\u50cf\u3092\u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u8868\u793a\r\n    \/\/\u30ab\u30e1\u30e9\u753b\u50cf\u304b\u3089\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0\u7528\u306e\u753b\u50cf\u306b\u5909\u63db\u3057\u30b3\u30d4\u30fc\r\n    img.copy(cam, 0, 0, cam.width, cam.height, 0, 0, img.width, img.height);\r\n    theBlobDetection.computeBlobs(img.pixels);  \/\/\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u63a2\u3059\r\n    drawEdges(true);    \/\/\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5468\u8fba\u3092\u63cf\u304f\r\n  }\r\n}\r\n\r\n\/\/ ==================================================\r\n\/\/ drawBlobsAndEdges()\r\n\/\/ ==================================================\r\nvoid drawEdges(boolean drawEdges){\r\n  noFill();\r\n  Blob b;    \/\/\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u7528\u306e\u5909\u6570\r\n  EdgeVertex eA,eB;    \/\/\u30a8\u30c3\u30b8\u306e\u70b9\r\n  \r\n  \/\/n\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u6570\r\n  for (int n=0 ; n<theblobdetection .getBlobNb() ; n++){\r\n    b=theBlobDetection.getBlob(n);\r\n    if (b!=null){  \/\/\u3082\u3057\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u3042\u3063\u305f\u3089\u3001\r\n      \/\/ Edges\r\n      if (drawEdges){\r\n        fill(0,0,255, 127);\r\n        for (int m=0;m<b.getEdgeNb();m++){\r\n          eA = b.getEdgeVertexA(m);  \/\/\u30a8\u30c3\u30b8\u306e\u70b9\u3092\u305d\u308c\u305e\u308ceA,eB\u306b\u4ee3\u5165\r\n          eB = b.getEdgeVertexB(m);\r\n          if (eA !=null &#038;&#038; eB !=null){\r\n            \/\/\u7dda\u3092\u63cf\u304f\r\n            \/\/line(eA.x*width, eA.y*height, eB.x*width, eB.y*height);\r\n            \/\/\u5186\u3092\u63cf\u304f\r\n            ellipse(eA.x*width, eA.y*height, 20, 20);\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8f2a\u90ed\u3092\u691c\u51fa\u3059\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,11],"tags":[],"class_list":["post-1652","post","type-post","status-publish","format-standard","hentry","category-processing","category-11"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/comments?post=1652"}],"version-history":[{"count":3,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1652\/revisions"}],"predecessor-version":[{"id":2471,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1652\/revisions\/2471"}],"wp:attachment":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/media?parent=1652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/categories?post=1652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/tags?post=1652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}