{"id":1516,"date":"2015-06-23T23:07:06","date_gmt":"2015-06-23T15:07:06","guid":{"rendered":"http:\/\/www.magicandlove.com\/blog\/?p=1516"},"modified":"2015-07-05T22:13:07","modified_gmt":"2015-07-05T14:13:07","slug":"opencv-and-processing-12","status":"publish","type":"post","link":"http:\/\/www.magicandlove.com\/blog\/2015\/06\/23\/opencv-and-processing-12\/","title":{"rendered":"OpenCV and Processing 12"},"content":{"rendered":"<p>The example again adopts the CVImage to demonstrate the use of blur filter. It uses the <strong>medianBlur() <\/strong>function from the Imgproc module in OpenCV. Detailed description can also be found in <a href=\"http:\/\/docs.opencv.org\/3.0-beta\/doc\/tutorials\/imgproc\/gausian_median_blur_bilateral_filter\/gausian_median_blur_bilateral_filter.html#smoothing\">the OpenCV tutorial here<\/a>. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2015\/06\/screen0177.png\" alt=\"\" title=\"screen0177\" width=\"640\" height=\"480\" class=\"alignnone size-full wp-image-1518\" srcset=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2015\/06\/screen0177.png 640w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2015\/06\/screen0177-300x225.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><br \/>\n<!--more--><\/p>\n<pre lang=\"java\">\r\nimport processing.video.*;\r\n\r\nimport org.opencv.imgproc.Imgproc;\r\nimport org.opencv.core.CvType;\r\nimport org.opencv.core.Size;\r\n\r\nCapture cap;\r\nCVImage img;\r\nPShape shp;\r\n\r\nvoid setup() {\r\n  size(640, 480, P3D);\r\n  println(Core.VERSION);\r\n  System.loadLibrary(Core.NATIVE_LIBRARY_NAME);\r\n  cap = new Capture(this, width, height);\r\n  cap.start();\r\n  img = new CVImage(width, height);\r\n  shp = createShape(RECT, 0, 0, width, height);\r\n}\r\n\r\nvoid draw() {\r\n  background(0);\r\n  arrayCopy(cap.pixels, img.pixels);\r\n  img.toCV(); \/\/ load the pixels to Mat\r\n\r\n  Mat src = img.getBGR();\r\n  Mat dst = new Mat(src.size(), src.type());\r\n  Imgproc.medianBlur(src, dst, 9);\r\n\r\n  img.fromCV(dst); \/\/ update the img with Mat dst\r\n  shp.setTexture(img);\r\n  shape(shp, 0, 0);\r\n  text(\"Frame rate: \" + nf(round(frameRate), 2), 10, 20);\r\n  src.release();\r\n  dst.release();\r\n}\r\n\r\nvoid captureEvent(Capture c) {\r\n  c.read();\r\n  c.loadPixels();\r\n}\r\n<\/pre>\n<p>&nbsp;<br \/>\nThe major statement is<\/p>\n<pre lang=\"java\">\r\nImgproc.medianBlur(src, dst, 9);\r\n<\/pre>\n<p>The number 9 is the aperture linear size to control the amount of &#8216;blurriness&#8217;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The example again adopts the CVImage to demonstrate the use of blur filter. It uses the medianBlur() function from the Imgproc module in OpenCV. Detailed description can also be found in the OpenCV tutorial here.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89,79],"tags":[128,3,62],"class_list":["post-1516","post","type-post","status-publish","format-standard","hentry","category-research","category-software-2","tag-image-processing","tag-opencv","tag-processing-org"],"_links":{"self":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/1516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/comments?post=1516"}],"version-history":[{"count":4,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/1516\/revisions"}],"predecessor-version":[{"id":1556,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/1516\/revisions\/1556"}],"wp:attachment":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/media?parent=1516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/categories?post=1516"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/tags?post=1516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}