├── JSARToolKit.js ├── JSARToolKit.min.js ├── LICENSE.txt ├── README ├── bundle.sh ├── conversion_scripts ├── create_test.rb ├── munge_as_to_js.rb └── parse_order.rb ├── demos ├── AR_simple_webgl.html ├── AR_slideshow │ ├── 2362652089_baaa1958d0_z.jpg │ ├── 2362676389_b0a145fce4_z.jpg │ ├── 2414463667_a173b81c3b_z.jpg │ ├── 2414466051_4a0c1b3617_z.jpg │ ├── 2430707122_df6e2b7c82_z.jpg │ ├── 2430716428_df5b41dd30_z.jpg │ ├── 2430719114_709bc64042_z.jpg │ ├── 2430721656_a16e70e1fa_z.jpg │ ├── 2484315925_4d47b261d0_z.jpg │ ├── 2484327283_c6bbd619c7_z.jpg │ ├── 2532453477_a3eeb02e40_z.jpg │ ├── 2554617303_ed7e668c24_z.jpg │ ├── 2555451906_9266de66fb_z.jpg │ ├── 2582668178_0cb5bc3524_z.jpg │ ├── 2633061658_66c1ef1d75_z.jpg │ ├── 2925126967_7ee0fabf0e_z.jpg │ ├── 2925128257_14e7db9032_z.jpg │ ├── 2925132353_cc796f58d9_z.jpg │ ├── 2925133991_e476527b9c_z.jpg │ ├── 2925984626_bf837a9c7e_z.jpg │ ├── AR_mediaStream.html │ ├── AR_slideshow.html │ ├── marker.png │ ├── photos2.xml │ ├── photos_public.xml │ └── swap_loop.ogg ├── images │ ├── armchair.jpg │ ├── chalk.jpg │ ├── chalk_multi.jpg │ ├── grand_vizier.jpg │ └── kuva.jpg ├── magi.js ├── markers │ ├── 0 │ ├── 1 │ ├── 2 │ ├── 3 │ ├── 4 │ ├── 5 │ ├── 6 │ ├── 7 │ ├── 8 │ ├── 9 │ ├── 10 │ ├── 11 │ ├── 12 │ ├── 13 │ ├── 14 │ ├── 15 │ ├── 16 │ ├── 17 │ ├── 18 │ ├── 19 │ ├── 20 │ ├── 21 │ ├── 22 │ ├── 23 │ ├── 24 │ ├── 25 │ ├── 26 │ ├── 27 │ ├── 28 │ ├── 29 │ ├── 30 │ ├── 31 │ ├── 32 │ ├── 33 │ ├── 34 │ ├── 35 │ ├── 36 │ ├── 37 │ ├── 38 │ ├── 39 │ ├── 40 │ ├── 41 │ ├── 42 │ ├── 43 │ ├── 44 │ ├── 45 │ ├── 46 │ ├── 47 │ ├── 48 │ ├── 49 │ ├── 50 │ ├── 51 │ ├── 52 │ ├── 53 │ ├── 54 │ ├── 55 │ ├── 56 │ ├── 57 │ ├── 58 │ ├── 59 │ ├── 60 │ ├── 61 │ ├── 62 │ ├── 63 │ ├── 64 │ ├── 65 │ ├── 66 │ ├── 67 │ ├── 68 │ ├── 69 │ ├── 70 │ ├── 71 │ ├── 72 │ ├── 73 │ ├── 74 │ ├── 75 │ ├── 76 │ ├── 77 │ ├── 78 │ ├── 79 │ ├── 80 │ ├── 81 │ ├── 82 │ ├── 83 │ ├── 84 │ ├── 85 │ ├── 86 │ ├── 87 │ ├── 88 │ ├── 89 │ ├── 90 │ ├── 91 │ ├── 92 │ ├── 93 │ ├── 94 │ ├── 95 │ ├── 96 │ ├── 97 │ ├── 98 │ └── 99 └── tests │ ├── output_4.ogg │ ├── test.html │ ├── test2.html │ ├── test3.html │ ├── test4.html │ ├── test5.html │ └── walas.binm ├── index.html ├── minify.sh └── src ├── FLARArrayUtil.js ├── FLARCode.js ├── FLARDetector.js ├── FLARException.js ├── FLARIdMarkerDetector.js ├── FLARLabeling.js ├── FLARMat.js ├── FLARParam.js ├── FLARProcessor.js ├── FLARRaster.js ├── FLARRasterAnalyzer.js ├── FLARRasterFilter.js ├── FLARRgbPixelReader.js ├── FLARSquareDetect.js ├── FLARTransMat.js ├── FLARTypes.js ├── NyARCode.js ├── NyARDetector.js ├── NyARHistogramAnalyzer.js ├── NyARIdMarker.js ├── NyARLabel.js ├── NyARMatch.js ├── NyARParam.js ├── NyARPca2d.js ├── NyARPickup.js ├── NyARRaster.js ├── NyARRasterAnalyzer.js ├── NyARRasterFilter.js ├── NyARRasterReader.js ├── NyARSingleMarkerProcesser.js ├── NyARSquareDetect.js ├── NyARTransMat.js ├── NyARTypes.js ├── NyARUtils.js ├── NyAs3Utils.js └── NyUtils.js /LICENSE.txt: -------------------------------------------------------------------------------- 1 | ====================================================================== 2 | JSARToolKit License 3 | ====================================================================== 4 | JSARToolKit 5 | Copyright (C)2010-2011 Ilmari Heikkinen 6 | 7 | Based on FLARToolKit (C)2008-2010 Saqoosha, Ryo Iizuka 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | 23 | FLARToolKit 24 | Copyright (C)2008-2010 Saqoosha, Ryo Iizuka 25 | 26 | このプログラムはフリーソフトウェアです。あなたはこれを、フリーソフトウェア 27 | 財団によって発行されたGNU 一般公衆利用許諾書(バージョン3か、それ以降のバー 28 | ジョンのうちどれか)が定める条件の下で再頒布または改変 することができます。 29 | 30 | このプログラムは有用であることを願って頒布されますが、*全くの無保証 *です。 31 | 商業可能性の保証や特定目的への適合性は、言外に示されたものも 含め、全く存 32 | 在しません。詳しくはGNU 一般公衆利用許諾書をご覧ください。 33 | 34 | あなたはこのプログラムと共に、GNU 一般公衆利用許諾書のコピーを一部受け取って 35 | いるはずです。もし受け取っていなければ、 を 36 | ご覧ください。 37 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | JSARToolkit 2 | -------------------------------------------------------------------------------- 3 | 4 | This is a JavaScript port of FLARToolKit, operating on canvas images and 5 | video element contents. And hopefully one day on device elements with webcam 6 | input. 7 | 8 | The license is GPL 3 as was the original library. If you use it in your own scripts, you need to make the unminified unobfuscated source code of your script available and licensed under GPL 3. 9 | 10 | All the hard work was done by the ARToolKit/NyARToolKit/FLARToolKit people, 11 | a huge thank you to them. This port was quite mechanical, though it has some 12 | major JS optimizations and a tracking robustness hack or two. And some 13 | uninformed bogus hacks in FLARParam to sort-of make it work on 16:9 video. 14 | 15 | See demos/AR_simple_webgl.html for an example of integrating JSARToolKit 16 | output with a WebGL program. 17 | 18 | I've only tested the ID markers and square detection paths, so you may 19 | encounter problems working with custom markers. In which case, filing a bug 20 | report on GitHub would be very much appreciated. 21 | 22 | 23 | - Ilmari Heikkinen 24 | 25 | -------------------------------------------------------------------------------- 26 | This work is based on the original ARToolKit developed by 27 | Hirokazu Kato 28 | Mark Billinghurst 29 | HITLab, University of Washington, Seattle 30 | http://www.hitl.washington.edu/artoolkit/ 31 | 32 | And the NyARToolkitAS3 ARToolKit class library. 33 | Copyright (C)2010 Ryo Iizuka 34 | 35 | The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 36 | Copyright (C)2008 Saqoosha 37 | 38 | JSARToolkit is a JavaScript port of NyARToolkitAS3 and FLARToolKit. 39 | Copyright (C)2011 Ilmari Heikkinen 40 | -------------------------------------------------------------------------------- /bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat \ 3 | src/NyAs3Utils.js \ 4 | src/FLARArrayUtil.js \ 5 | src/FLARException.js \ 6 | src/FLARMat.js \ 7 | src/FLARRgbPixelReader.js \ 8 | src/NyARHistogramAnalyzer.js \ 9 | src/NyARPca2d.js \ 10 | src/NyARRasterReader.js \ 11 | src/NyARTypes.js \ 12 | src/FLARRasterFilter.js \ 13 | src/FLARTypes.js \ 14 | src/NyARLabel.js \ 15 | src/FLARLabeling.js \ 16 | src/NyARParam.js \ 17 | src/FLARParam.js \ 18 | src/NyARRaster.js \ 19 | src/FLARRaster.js \ 20 | src/NyARCode.js \ 21 | src/FLARCode.js \ 22 | src/NyARMatch.js \ 23 | src/NyARRasterAnalyzer.js \ 24 | src/FLARRasterAnalyzer.js \ 25 | src/NyARRasterFilter.js \ 26 | src/NyARSquareDetect.js \ 27 | src/FLARSquareDetect.js \ 28 | src/NyARTransMat.js \ 29 | src/FLARTransMat.js \ 30 | src/NyARUtils.js \ 31 | src/NyARIdMarker.js \ 32 | src/NyARPickup.js \ 33 | src/FLARProcessor.js \ 34 | src/NyARDetector.js \ 35 | src/FLARDetector.js \ 36 | src/FLARIdMarkerDetector.js \ 37 | src/NyARSingleMarkerProcesser.js \ 38 | src/NyUtils.js \ 39 | > JSARToolKit.js 40 | -------------------------------------------------------------------------------- /conversion_scripts/create_test.rb: -------------------------------------------------------------------------------- 1 | s=`ruby parse_order.rb` 2 | File.open("test.html", 'w'){|f| 3 | f.write("#{s}") 4 | } 5 | -------------------------------------------------------------------------------- /conversion_scripts/munge_as_to_js.rb: -------------------------------------------------------------------------------- 1 | license = <. 26 | * 27 | * For further information please contact. 28 | * http://nyatla.jp/nyatoolkit/ 29 | * or 30 | * 31 | */ 32 | ENDL 33 | license.strip! 34 | new_license = <. 62 | * 63 | * For further information please contact. 64 | * ilmari.heikkinen@gmail.com 65 | * 66 | */ 67 | ENDL 68 | new_license.strip! 69 | 70 | Dir["*.as"].each do |fn| 71 | s = File.read(fn) 72 | s.gsub!(/\s+$/, "") 73 | s.gsub!(/\t/, " ") 74 | s.sub!(license, new_license) 75 | s.gsub!(license, "") 76 | s.gsub!(/^\{/, "") 77 | s.gsub!(/^\}/, "") 78 | s.gsub!(/^\s*package .*/, "") 79 | s.gsub!(/^ /, "") 80 | s.gsub!(/^\}/, "})") 81 | s.gsub!(/^\s*import .*/, "") 82 | s.gsub!(/^\s*(final )?(public |private |protected )?(static )?(internal ?)(class|interface) (\S+)/, "\\5 = ASKlass('\\5',") 83 | s.gsub!(/^\s*import .*/, "") 84 | s.gsub!(/ extends\s+(\S+)/, " \\1,") 85 | s.gsub!(/ implements\s+(\S+)/, "") 86 | s.gsub!(/(final )?(public|private|protected) (final )?(static )?(var|const) ([^;]+);/){|m| 87 | k = $6 88 | if k.include?("=") 89 | name,value = k.strip.split(/\s*=\s*/,2) 90 | ",#{name} : #{value}" 91 | elsif k =~ /:(Number|int|float|[dD]ouble)$/ 92 | ",#{k} : 0" 93 | else 94 | ",#{k} : null" 95 | end 96 | } 97 | s.gsub!(/([a-zA-Z0-9_\[\]\(\)]+):[a-zA-Z0-9_\.<>]+/, "\\1") 98 | s.gsub!(/((final )?(public|private|protected) (final )?(override )?(static )?)?function ([^\(]+)/, ",\\7 : function") 99 | s.gsub!(/\bVector\.]+>>/, "Array") 100 | s.gsub!(/\bVector\./, "FloatVector") 101 | s.gsub!(/\bVector\./, "IntVector") 102 | s.gsub!(/\bVector\.<[^>]+>/, "Array") 103 | s.gsub!(/(function\s*\([^\)]*\))\s*;/, "\\1{},") 104 | s.gsub!(/,(\s*(\/\/[^\n]*\n|\/\*([^*]*\*[^\/])+[^*]*\*\/)*\s*),/m, ",\\1") 105 | s.gsub!(/\{(\s*(\/\/[^\n]*\n|\/\*([^*]*\*[^\/])+[^*]*\*\/)*\s*),/m, "{\\1") 106 | s.gsub!(/\,(\s*(\/\/[^\n]*\n|\/\*([^*]*\*[^\/])+[^*]*\*\/)*\s*)\}/m, "\\1}") 107 | s.gsub!(/\[(\s*(\/\/[^\n]*\n|\/\*([^*]*\*[^\/])+[^*]*\*\/)*\s*),/m, "[\\1") 108 | s.gsub!(/\,(\s*(\/\/[^\n]*\n|\/\*([^*]*\*[^\/])+[^*]*\*\/)*\s*)\]/m, "\\1]") 109 | File.open(fn.sub(/as$/,"js"), "w"){|f| f.write s } 110 | end 111 | 112 | -------------------------------------------------------------------------------- /conversion_scripts/parse_order.rb: -------------------------------------------------------------------------------- 1 | files = []; 2 | 3 | Dir["src/*.js"].sort.each{|js| 4 | lines = File.readlines(js) 5 | class_lines = lines.grep(/Klass| [A-Z][^\.\(;\s]+[\.\(;]|^\}\)$/).reject{|f| f =~ /\s*\*/} 6 | objs = [] 7 | cobj = nil 8 | class_lines.each{|cl| 9 | cl.gsub!(/"[^"]+"/, "") 10 | if cl =~ /^\}\)/ 11 | objs.push(cobj) if cobj 12 | cobj = nil 13 | elsif cl =~ /^\S+ =/ 14 | cname,rest = cl.split(" ",2) 15 | objs.push(cobj) if cobj 16 | cobj = [cname, rest.scan(/\b[A-Z][a-zA-Z0-9_]+/)] 17 | elsif cobj 18 | cobj[1].push(*cl.scan(/\b[A-Z][a-zA-Z0-9_]+/)) 19 | else 20 | cobj = [nil, cl.scan(/\b[A-Z][a-zA-Z0-9_]+/)] 21 | end 22 | } 23 | objs.push(cobj) if cobj 24 | objs.each{|c| c[1].uniq! } 25 | classes = objs.map{|c| c[0] }.compact.uniq.sort 26 | constructors = classes.map{|c| lines.grep(/#{c} : function/) }.flatten.compact 27 | constructors.map!{|c| c.gsub(/^\s*\*?\s*,?| : function/,'') }.reject{|c|c =~ /^[a-z]/ } 28 | files.push({ 29 | :file => js, 30 | :deps => objs.map{|c| c[1] }.flatten.sort.uniq - classes, 31 | :provides => classes, 32 | :constructors => constructors, 33 | :class_deps => objs 34 | }) 35 | } 36 | def compare_files(a,b) 37 | return 0 if a == b 38 | b_needs_a = (b[:deps] - a[:provides]).length < b[:deps].length 39 | a_needs_b = (a[:deps] - b[:provides]).length < a[:deps].length 40 | if b_needs_a and a_needs_b 41 | puts "Conflict between #{a[:file]} and #{b[:file]}" 42 | 0 43 | elsif a_needs_b 44 | 1 45 | elsif b_needs_a 46 | -1 47 | else 48 | 0 49 | end 50 | end 51 | def sort_by_deps(files) 52 | sfiles = [] 53 | while files.length > 0 54 | m = files.find{|f| files.all?{|g| compare_files(f,g) < 1 } } 55 | raise "no find" unless m 56 | files.delete(m) 57 | sfiles.push(m) 58 | end 59 | sfiles 60 | end 61 | files = sort_by_deps(files) 62 | 63 | puts( files.map{|f| "" } ) 64 | puts("") 65 | -------------------------------------------------------------------------------- /demos/AR_simple_webgl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /demos/AR_slideshow/2362652089_baaa1958d0_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2362652089_baaa1958d0_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2362676389_b0a145fce4_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2362676389_b0a145fce4_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2414463667_a173b81c3b_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2414463667_a173b81c3b_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2414466051_4a0c1b3617_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2414466051_4a0c1b3617_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2430707122_df6e2b7c82_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2430707122_df6e2b7c82_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2430716428_df5b41dd30_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2430716428_df5b41dd30_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2430719114_709bc64042_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2430719114_709bc64042_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2430721656_a16e70e1fa_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2430721656_a16e70e1fa_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2484315925_4d47b261d0_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2484315925_4d47b261d0_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2484327283_c6bbd619c7_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2484327283_c6bbd619c7_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2532453477_a3eeb02e40_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2532453477_a3eeb02e40_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2554617303_ed7e668c24_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2554617303_ed7e668c24_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2555451906_9266de66fb_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2555451906_9266de66fb_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2582668178_0cb5bc3524_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2582668178_0cb5bc3524_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2633061658_66c1ef1d75_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2633061658_66c1ef1d75_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2925126967_7ee0fabf0e_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2925126967_7ee0fabf0e_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2925128257_14e7db9032_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2925128257_14e7db9032_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2925132353_cc796f58d9_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2925132353_cc796f58d9_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2925133991_e476527b9c_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2925133991_e476527b9c_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/2925984626_bf837a9c7e_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/2925984626_bf837a9c7e_z.jpg -------------------------------------------------------------------------------- /demos/AR_slideshow/marker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/marker.png -------------------------------------------------------------------------------- /demos/AR_slideshow/swap_loop.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/AR_slideshow/swap_loop.ogg -------------------------------------------------------------------------------- /demos/images/armchair.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/images/armchair.jpg -------------------------------------------------------------------------------- /demos/images/chalk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/images/chalk.jpg -------------------------------------------------------------------------------- /demos/images/chalk_multi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/images/chalk_multi.jpg -------------------------------------------------------------------------------- /demos/images/grand_vizier.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/images/grand_vizier.jpg -------------------------------------------------------------------------------- /demos/images/kuva.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/images/kuva.jpg -------------------------------------------------------------------------------- /demos/markers/0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/0 -------------------------------------------------------------------------------- /demos/markers/1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/1 -------------------------------------------------------------------------------- /demos/markers/10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/10 -------------------------------------------------------------------------------- /demos/markers/11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/11 -------------------------------------------------------------------------------- /demos/markers/12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/12 -------------------------------------------------------------------------------- /demos/markers/13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/13 -------------------------------------------------------------------------------- /demos/markers/14: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/14 -------------------------------------------------------------------------------- /demos/markers/15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/15 -------------------------------------------------------------------------------- /demos/markers/16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/16 -------------------------------------------------------------------------------- /demos/markers/17: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/17 -------------------------------------------------------------------------------- /demos/markers/18: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/18 -------------------------------------------------------------------------------- /demos/markers/19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/19 -------------------------------------------------------------------------------- /demos/markers/2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/2 -------------------------------------------------------------------------------- /demos/markers/20: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/20 -------------------------------------------------------------------------------- /demos/markers/21: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/21 -------------------------------------------------------------------------------- /demos/markers/22: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/22 -------------------------------------------------------------------------------- /demos/markers/23: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/23 -------------------------------------------------------------------------------- /demos/markers/24: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/24 -------------------------------------------------------------------------------- /demos/markers/25: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/25 -------------------------------------------------------------------------------- /demos/markers/26: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/26 -------------------------------------------------------------------------------- /demos/markers/27: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/27 -------------------------------------------------------------------------------- /demos/markers/28: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/28 -------------------------------------------------------------------------------- /demos/markers/29: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/29 -------------------------------------------------------------------------------- /demos/markers/3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/3 -------------------------------------------------------------------------------- /demos/markers/30: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/30 -------------------------------------------------------------------------------- /demos/markers/31: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/31 -------------------------------------------------------------------------------- /demos/markers/32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/32 -------------------------------------------------------------------------------- /demos/markers/33: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/33 -------------------------------------------------------------------------------- /demos/markers/34: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/34 -------------------------------------------------------------------------------- /demos/markers/35: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/35 -------------------------------------------------------------------------------- /demos/markers/36: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/36 -------------------------------------------------------------------------------- /demos/markers/37: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/37 -------------------------------------------------------------------------------- /demos/markers/38: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/38 -------------------------------------------------------------------------------- /demos/markers/39: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/39 -------------------------------------------------------------------------------- /demos/markers/4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/4 -------------------------------------------------------------------------------- /demos/markers/40: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/40 -------------------------------------------------------------------------------- /demos/markers/41: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/41 -------------------------------------------------------------------------------- /demos/markers/42: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/42 -------------------------------------------------------------------------------- /demos/markers/43: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/43 -------------------------------------------------------------------------------- /demos/markers/44: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/44 -------------------------------------------------------------------------------- /demos/markers/45: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/45 -------------------------------------------------------------------------------- /demos/markers/46: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/46 -------------------------------------------------------------------------------- /demos/markers/47: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/47 -------------------------------------------------------------------------------- /demos/markers/48: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/48 -------------------------------------------------------------------------------- /demos/markers/49: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/49 -------------------------------------------------------------------------------- /demos/markers/5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/5 -------------------------------------------------------------------------------- /demos/markers/50: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/50 -------------------------------------------------------------------------------- /demos/markers/51: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/51 -------------------------------------------------------------------------------- /demos/markers/52: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/52 -------------------------------------------------------------------------------- /demos/markers/53: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/53 -------------------------------------------------------------------------------- /demos/markers/54: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/54 -------------------------------------------------------------------------------- /demos/markers/55: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/55 -------------------------------------------------------------------------------- /demos/markers/56: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/56 -------------------------------------------------------------------------------- /demos/markers/57: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/57 -------------------------------------------------------------------------------- /demos/markers/58: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/58 -------------------------------------------------------------------------------- /demos/markers/59: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/59 -------------------------------------------------------------------------------- /demos/markers/6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/6 -------------------------------------------------------------------------------- /demos/markers/60: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/60 -------------------------------------------------------------------------------- /demos/markers/61: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/61 -------------------------------------------------------------------------------- /demos/markers/62: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/62 -------------------------------------------------------------------------------- /demos/markers/63: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/63 -------------------------------------------------------------------------------- /demos/markers/64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/64 -------------------------------------------------------------------------------- /demos/markers/65: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/65 -------------------------------------------------------------------------------- /demos/markers/66: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/66 -------------------------------------------------------------------------------- /demos/markers/67: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/67 -------------------------------------------------------------------------------- /demos/markers/68: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/68 -------------------------------------------------------------------------------- /demos/markers/69: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/69 -------------------------------------------------------------------------------- /demos/markers/7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/7 -------------------------------------------------------------------------------- /demos/markers/70: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/70 -------------------------------------------------------------------------------- /demos/markers/71: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/71 -------------------------------------------------------------------------------- /demos/markers/72: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/72 -------------------------------------------------------------------------------- /demos/markers/73: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/73 -------------------------------------------------------------------------------- /demos/markers/74: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/74 -------------------------------------------------------------------------------- /demos/markers/75: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/75 -------------------------------------------------------------------------------- /demos/markers/76: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/76 -------------------------------------------------------------------------------- /demos/markers/77: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/77 -------------------------------------------------------------------------------- /demos/markers/78: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/78 -------------------------------------------------------------------------------- /demos/markers/79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/79 -------------------------------------------------------------------------------- /demos/markers/8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/8 -------------------------------------------------------------------------------- /demos/markers/80: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/80 -------------------------------------------------------------------------------- /demos/markers/81: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/81 -------------------------------------------------------------------------------- /demos/markers/82: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/82 -------------------------------------------------------------------------------- /demos/markers/83: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/83 -------------------------------------------------------------------------------- /demos/markers/84: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/84 -------------------------------------------------------------------------------- /demos/markers/85: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/85 -------------------------------------------------------------------------------- /demos/markers/86: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/86 -------------------------------------------------------------------------------- /demos/markers/87: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/87 -------------------------------------------------------------------------------- /demos/markers/88: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/88 -------------------------------------------------------------------------------- /demos/markers/89: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/89 -------------------------------------------------------------------------------- /demos/markers/9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/9 -------------------------------------------------------------------------------- /demos/markers/90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/90 -------------------------------------------------------------------------------- /demos/markers/91: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/91 -------------------------------------------------------------------------------- /demos/markers/92: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/92 -------------------------------------------------------------------------------- /demos/markers/93: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/93 -------------------------------------------------------------------------------- /demos/markers/94: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/94 -------------------------------------------------------------------------------- /demos/markers/95: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/95 -------------------------------------------------------------------------------- /demos/markers/96: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/96 -------------------------------------------------------------------------------- /demos/markers/97: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/97 -------------------------------------------------------------------------------- /demos/markers/98: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/98 -------------------------------------------------------------------------------- /demos/markers/99: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/markers/99 -------------------------------------------------------------------------------- /demos/tests/output_4.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/tests/output_4.ogg -------------------------------------------------------------------------------- /demos/tests/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 220 | 221 | -------------------------------------------------------------------------------- /demos/tests/test2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 184 | 185 | -------------------------------------------------------------------------------- /demos/tests/test3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 285 | 286 | 287 | 288 |
289 | 290 | 291 |
292 | 293 | 294 | -------------------------------------------------------------------------------- /demos/tests/test4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 214 | 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /demos/tests/walas.binm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kig/JSARToolKit/01817463c089c78096e75f72e86cf1ad4dba2134/demos/tests/walas.binm -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | JSARToolKit Demos 3 | 4 |

JSARToolKit Demos

5 |

Canvas 2D Demos

6 | 9 |

WebGL Demos

10 | 16 | 17 |

Download

18 |

19 | Get the code from GitHub 20 |

21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /minify.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat \ 3 | src/NyAs3Utils.js \ 4 | src/FLARArrayUtil.js \ 5 | src/FLARException.js \ 6 | src/FLARMat.js \ 7 | src/FLARRgbPixelReader.js \ 8 | src/NyARHistogramAnalyzer.js \ 9 | src/NyARPca2d.js \ 10 | src/NyARRasterReader.js \ 11 | src/NyARTypes.js \ 12 | src/FLARRasterFilter.js \ 13 | src/FLARTypes.js \ 14 | src/NyARLabel.js \ 15 | src/FLARLabeling.js \ 16 | src/NyARParam.js \ 17 | src/FLARParam.js \ 18 | src/NyARRaster.js \ 19 | src/FLARRaster.js \ 20 | src/NyARCode.js \ 21 | src/FLARCode.js \ 22 | src/NyARMatch.js \ 23 | src/NyARRasterAnalyzer.js \ 24 | src/FLARRasterAnalyzer.js \ 25 | src/NyARRasterFilter.js \ 26 | src/NyARSquareDetect.js \ 27 | src/FLARSquareDetect.js \ 28 | src/NyARTransMat.js \ 29 | src/FLARTransMat.js \ 30 | src/NyARUtils.js \ 31 | src/NyARIdMarker.js \ 32 | src/NyARPickup.js \ 33 | src/FLARProcessor.js \ 34 | src/NyARDetector.js \ 35 | src/FLARDetector.js \ 36 | src/FLARIdMarkerDetector.js \ 37 | src/NyARSingleMarkerProcesser.js \ 38 | src/NyUtils.js \ 39 | | yui-compressor --type js > JSARToolKit.min.js 40 | -------------------------------------------------------------------------------- /src/FLARArrayUtil.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation; either version 2 14 | * of the License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this framework; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * For further information please contact. 26 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 27 | * 28 | * 29 | */ 30 | ArrayUtil = ASKlass('ArrayUtil', { 31 | createJaggedArray : function(len) { 32 | var arr = new Array(len); 33 | var args = toArray(arguments).slice(1); 34 | while (len--) { 35 | arr[len] = args.length ? this.createJaggedArray.apply(null, args) : 0; 36 | } 37 | return arr; 38 | } 39 | ,create2d : function(height, width) { 40 | return this.createJaggedArray(height, width); 41 | } 42 | ,create3d : function(depth, height, width) { 43 | return this.createJaggedArray(depth, height, width); 44 | } 45 | ,copy : function(src, srcPos, dest, destPos, length) { 46 | for (var i = 0; i < length; i++) { 47 | dest[destPos + i] = src[srcPos + i]; 48 | } 49 | } 50 | }) 51 | -------------------------------------------------------------------------------- /src/FLARCode.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | FLARCode = ASKlass('FLARCode', NyARCode, 30 | { 31 | markerPercentWidth : 50 32 | ,markerPercentHeight : 50 33 | /** 34 | * 35 | * @param i_width 幅方向の分割数 36 | * @param i_height 高さ方向の分割数 37 | * @param i_markerPercentWidth マーカ全体(本体+枠)における、マーカ本体部分の割合(幅) 38 | * @param i_markerPercentHeight マーカ全体(本体+枠)における、マーカ本体部分の割合(高さ) 39 | */ 40 | ,FLARCode : function(i_width, i_height,i_markerPercentWidth, i_markerPercentHeight) 41 | { 42 | NyARCode.initialize.call(this, i_width, i_height); 43 | this.markerPercentWidth = i_markerPercentWidth == null ? 50 : i_markerPercentWidth; 44 | this.markerPercentHeight = i_markerPercentHeight == null ? 50 : i_markerPercentHeight; 45 | } 46 | ,loadARPatt : function(i_stream) 47 | { 48 | NyARCode.loadARPattFromFile.call(this, i_stream); 49 | return; 50 | } 51 | }) 52 | -------------------------------------------------------------------------------- /src/FLARException.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation; either version 2 14 | * of the License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this framework; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * For further information please contact. 26 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 27 | * 28 | * 29 | */ 30 | FLARException = ASKlass('FLARException', NyARException, 31 | { 32 | FLARException : function(m) 33 | { 34 | NyARException.initialize.call(this,m||''); 35 | } 36 | ,trap : function(m) 37 | { 38 | throw new FLARException("trap:" + m); 39 | } 40 | ,notImplement : function() 41 | { 42 | throw new FLARException("Not Implement!"); 43 | } 44 | }) 45 | -------------------------------------------------------------------------------- /src/FLARLabeling.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | FLARLabeling = ASKlass('FLARLabeling', 30 | { 31 | AR_AREA_MAX : 100000// #define AR_AREA_MAX 100000 32 | ,AR_AREA_MIN : 70// #define AR_AREA_MIN 70 33 | ,ZERO_POINT : new Point() 34 | ,ONE_POINT : new Point(1, 1) 35 | ,hSearch : null 36 | ,hLineRect : null 37 | ,_tmp_bmp : null 38 | ,areaMax : 0 39 | ,areaMin : 0 40 | ,FLARLabeling : function(i_width,i_height) 41 | { 42 | this._tmp_bmp = new BitmapData(i_width, i_height, false,0x00); 43 | this.hSearch = new BitmapData(i_width, 1, false, 0x000000); 44 | this.hLineRect = new Rectangle(0, 0, 1, 1); 45 | this.setAreaRange(this.AR_AREA_MAX, this.AR_AREA_MIN); 46 | return; 47 | } 48 | /** 49 | * 白領域の検査対象サイズ 50 | * 最大サイズは 一辺約320px、最小サイズは 一辺約 8px まで解析対象としている 51 | * 解析画像中で上記範囲内であれば解析対象となるが、最小サイズは小さすぎて意味をなさない。 52 | * 53 | * @param i_max 解析対象とする白領域の最大pixel数(一辺の二乗) 54 | * @param i_min 解析対象とする白領域の最小pixel数(一辺の二乗) 55 | */ 56 | ,setAreaRange : function(i_max, i_min) 57 | { 58 | this.areaMax=i_max; 59 | this.areaMin=i_min; 60 | } 61 | ,labeling : function(i_bin_raster,o_stack) 62 | { 63 | var label_img = this._tmp_bmp; 64 | label_img.fillRect(label_img.rect, 0x0); 65 | var rect = label_img.rect.clone(); 66 | rect.inflate(-1, -1); 67 | label_img.copyPixels(i_bin_raster.getBuffer(), rect, this.ONE_POINT); 68 | var currentRect = label_img.getColorBoundsRect(0xffffff, 0xffffff, true); 69 | var hLineRect = this.hLineRect; 70 | hLineRect.y = 0; 71 | hLineRect.width = label_img.width; 72 | var hSearch = this.hSearch; 73 | var hSearchRect; 74 | var labelRect; 75 | var index = 0; 76 | var label; 77 | o_stack.clear(); 78 | // try { 79 | while (!currentRect.isEmpty()) { 80 | hLineRect.y = currentRect.top; 81 | hSearch.copyPixels(label_img, hLineRect, this.ZERO_POINT); 82 | hSearchRect = hSearch.getColorBoundsRect(0xffffff, 0xffffff, true); 83 | label_img.floodFill(hSearchRect.x, hLineRect.y, ++index); 84 | labelRect = label_img.getColorBoundsRect(0xffffff, index, true); 85 | label = o_stack.prePush(); 86 | var area = labelRect.width * labelRect.height; 87 | //エリア規制 88 | if (area <= this.areaMax && area >= this.areaMin){ 89 | label.area = area; 90 | label.clip_l = labelRect.left; 91 | label.clip_r = labelRect.right - 1; 92 | label.clip_t = labelRect.top; 93 | label.clip_b = labelRect.bottom - 1; 94 | label.pos_x = (labelRect.left + labelRect.right - 1) * 0.5; 95 | label.pos_y = (labelRect.top + labelRect.bottom - 1) * 0.5; 96 | //エントリ・ポイントを探す 97 | label.entry_x=this.getTopClipTangentX(label_img,index,label); 98 | if (label.entry_x == -1) { 99 | return -1; 100 | } 101 | }else { 102 | o_stack.pop(); 103 | } 104 | currentRect = label_img.getColorBoundsRect(0xffffff, 0xffffff, true); 105 | } 106 | /* } catch (e) { 107 | throw("too many labeled area!! gave up") 108 | console.log('Too many labeled area!! gave up....',e); 109 | }*/ 110 | return o_stack.getLength(); 111 | } 112 | ,getTopClipTangentX : function(i_image, i_index, i_label) 113 | { 114 | var w; 115 | var clip1 = i_label.clip_r; 116 | var i; 117 | for (i = i_label.clip_l; i <= clip1; i++) { // for( i = clip[0]; i <=clip[1]; i++, p1++ ) { 118 | w = i_image.getPixel(i, i_label.clip_t); 119 | if (w > 0 && w == i_index) { 120 | return i; 121 | } 122 | } 123 | //あれ?見つからないよ? 124 | return -1; 125 | } 126 | }) 127 | -------------------------------------------------------------------------------- /src/FLARMat.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | FLARMat = NyARMat; 30 | -------------------------------------------------------------------------------- /src/FLARParam.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | 30 | /** 31 | * typedef struct { int xsize, ysize; double mat[3][4]; double dist_factor[4]; } ARParam; 32 | * NyARの動作パラメータを格納するクラス 33 | * 34 | * @see jp.nyatla.nyartoolkit.as3.core.param.NyARParam 35 | */ 36 | FLARParam = ASKlass('FLARParam', NyARParam, 37 | { 38 | FLARParam : function(w,h) 39 | { 40 | w = w || 640; 41 | h = h || 480; 42 | this._screen_size.w = w; 43 | this._screen_size.h = h; 44 | var f = (w/h) / (4/3); 45 | var dist = new FloatVector([w/2, 1.1*h/2, 26.2, 1.0127565206658486]); 46 | var projection = new FloatVector([f*700.9514702992245, 0, w/2-0.5, 0, 47 | 0, 726.0941816535367, h/2-0.5, 0, 48 | 0, 0, 1, 0]); 49 | this.setValue(dist, projection); 50 | } 51 | 52 | }) 53 | -------------------------------------------------------------------------------- /src/FLARRaster.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | 30 | 31 | FLARCanvas = function(w,h) { 32 | var c = document.createElement('canvas'); 33 | c.width = w; 34 | c.height = h; 35 | return c; 36 | } 37 | 38 | 39 | 40 | FLARBinRaster = ASKlass('FLARBinRaster', NyARBinRaster, 41 | { 42 | FLARBinRaster : function(i_width,i_height) 43 | { 44 | NyARBinRaster.initialize.call(this,i_width,i_height,NyARBufferType.OBJECT_AS3_BitmapData,true); 45 | this._gray_reader = new FLARGrayPixelReader_BitmapData(this._buf); 46 | } 47 | ,initInstance : function(i_size,i_buf_type,i_is_alloc) 48 | { 49 | this._buf = i_is_alloc?new BitmapData(i_size.w,i_size.h,0x00):null; 50 | return true; 51 | } 52 | ,getGrayPixelReader : function() { 53 | return this._gray_reader; 54 | } 55 | }) 56 | 57 | 58 | FLARRgbRaster_BitmapData = ASKlass('FLARRgbRaster_BitmapData', NyARRgbRaster_BasicClass, 59 | { 60 | _bitmapData : null 61 | ,_rgb_reader : null 62 | /** 63 | * 64 | * @deprecated 次バージョンで次のように変更されます。 FLARRgbRaster_BitmapData(i_width,i_height) 65 | */ 66 | ,FLARRgbRaster_BitmapData : function(bitmapData) { 67 | NyARRgbRaster_BasicClass.initialize.call(this,bitmapData.width, bitmapData.height,NyARBufferType.OBJECT_AS3_BitmapData); 68 | this._bitmapData = bitmapData; 69 | this._rgb_reader = new FLARRgbPixelReader_BitmapData(this._bitmapData); 70 | } 71 | ,getRgbPixelReader : function() 72 | { 73 | return this._rgb_reader; 74 | } 75 | ,getBuffer : function() 76 | { 77 | return this._bitmapData; 78 | } 79 | ,hasBuffer : function() 80 | { 81 | return this._bitmapData != null; 82 | } 83 | }) 84 | -------------------------------------------------------------------------------- /src/FLARRasterAnalyzer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | FLARRasterAnalyzer_Histogram = ASKlass('FLARRasterAnalyzer_Histogram', NyARRasterAnalyzer_Histogram, 30 | { 31 | FLARRasterAnalyzer_Histogram : function(i_vertical_interval) 32 | { 33 | NyARRasterAnalyzer_Histogram.initialize.call(this,NyARBufferType.OBJECT_AS3_BitmapData,i_vertical_interval); 34 | } 35 | ,initInstance : function(i_raster_format,i_vertical_interval) 36 | { 37 | if (i_raster_format != NyARBufferType.OBJECT_AS3_BitmapData) { 38 | return false; 39 | }else { 40 | this._vertical_skip = i_vertical_interval; 41 | } 42 | return true; 43 | } 44 | /** 45 | * o_histgramにヒストグラムを出力します。 46 | * @param i_input 47 | * @param o_histgram 48 | * @return 49 | * @throws NyARException 50 | */ 51 | ,analyzeRaster : function(i_input,o_histgram) 52 | { 53 | var size=i_input.getSize(); 54 | //最大画像サイズの制限 55 | NyAS3Utils.assert(size.w*size.h<0x40000000); 56 | NyAS3Utils.assert(o_histgram.length == 256);//現在は固定 57 | var h=o_histgram.data; 58 | //ヒストグラム初期化 59 | for (var i = o_histgram.length-1; i >=0; i--){ 60 | h[i] = 0; 61 | } 62 | o_histgram.total_of_data=size.w*size.h/this._vertical_skip; 63 | return this.createHistgram_AS3_BitmapData(i_input, size,h,this._vertical_skip); 64 | } 65 | ,createHistgram_AS3_BitmapData : function(i_reader,i_size,o_histgram,i_skip) 66 | { 67 | //[Todo:]この方法だとパフォーマンスでないから、Bitmapdataの 68 | NyAS3Utils.assert (i_reader.isEqualBufferType(NyARBufferType.OBJECT_AS3_BitmapData)); 69 | var input=(i_reader.getBuffer()); 70 | for (var y = i_size.h-1; y >=0 ; y-=i_skip){ 71 | var pt=y*i_size.w; 72 | for (var x = i_size.w - 1; x >= 0; x--) { 73 | var p=input.getPixel(x,y); 74 | o_histgram[toInt((((p>>8)&0xff)+((p>>16)&0xff)+(p&0xff))/3)]++; 75 | pt++; 76 | } 77 | } 78 | return i_size.w*i_size.h; 79 | } 80 | }) 81 | 82 | /* 83 | * PROJECT: FLARToolKit 84 | * -------------------------------------------------------------------------------- 85 | * This work is based on the NyARToolKit developed by 86 | * R.Iizuka (nyatla) 87 | * http://nyatla.jp/nyatoolkit/ 88 | * 89 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 90 | * Copyright (C)2008 Saqoosha 91 | * 92 | * This program is free software: you can redistribute it and/or modify 93 | * it under the terms of the GNU General Public License as published by 94 | * the Free Software Foundation, either version 3 of the License, or 95 | * (at your option) any later version. 96 | * 97 | * This program is distributed in the hope that it will be useful, 98 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 99 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 100 | * GNU General Public License for more details. 101 | * 102 | * You should have received a copy of the GNU General Public License 103 | * along with this program. If not, see . 104 | * 105 | * For further information please contact. 106 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 107 | * 108 | * 109 | */ 110 | FLARRasterThresholdAnalyzer_SlidePTile = ASKlass('FLARRasterThresholdAnalyzer_SlidePTile', NyARRasterThresholdAnalyzer_SlidePTile, 111 | { 112 | FLARRasterThresholdAnalyzer_SlidePTile : function(i_persentage, i_vertical_interval) 113 | { 114 | NyARRasterThresholdAnalyzer_SlidePTile.initialize.call(this,i_persentage, NyARBufferType.OBJECT_AS3_BitmapData,i_vertical_interval); 115 | } 116 | ,initInstance : function(i_raster_format,i_vertical_interval) 117 | { 118 | if (i_raster_format != NyARBufferType.OBJECT_AS3_BitmapData) { 119 | return false; 120 | } 121 | this._raster_analyzer=new FLARRasterAnalyzer_Histogram(i_vertical_interval); 122 | return true; 123 | } 124 | }) 125 | -------------------------------------------------------------------------------- /src/FLARRasterFilter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | 30 | 31 | 32 | /** 33 | * 各ラスタ用のフィルタ実装 34 | */ 35 | IFLdoThFilterImpl = ASKlass('IFLdoThFilterImpl', 36 | { 37 | doThFilter : function(i_input,i_output,i_size,i_threshold){} 38 | }) 39 | 40 | 41 | /** 42 | * 定数閾値による2値化をする。 43 | * 44 | */ 45 | FLARRasterFilter_Threshold = ASKlass('FLARRasterFilter_Threshold', 46 | { 47 | _threshold : 0 48 | ,_do_threshold_impl : null 49 | ,FLARRasterFilter_Threshold : function(i_threshold) 50 | { 51 | } 52 | /** 53 | * 画像を2値化するための閾値。暗点<=th<明点となります。 54 | * @param i_threshold 55 | */ 56 | ,setThreshold : function(i_threshold ) 57 | { 58 | this._threshold = i_threshold; 59 | } 60 | ,doFilter : function(i_input, i_output) 61 | { 62 | NyAS3Utils.assert (i_input._width == i_output._width && i_input._height == i_output._height); 63 | var out_buf = (i_output.getBuffer()); 64 | var in_reader = i_input.getRgbPixelReader(); 65 | var d = in_reader.getData().data; 66 | var obd = out_buf.data; 67 | var th3 = this._threshold*10000; 68 | for (var i=0,j=0; i>16)&0xff)*0.2989 + ((dc>>8)&0xff)*0.5866 + (dc&0xff)*0.1145; 95 | var f = (c <= i_threshold); 96 | var t = f*0xffffffff + (1-f)*0xff000000; 97 | obd[j] = t; 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /src/FLARRgbPixelReader.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | FLARRgbPixelReader_BitmapData = ASKlass('FLARRgbPixelReader_BitmapData', 30 | { 31 | _ref_bitmap : null 32 | ,FLARRgbPixelReader_BitmapData : function(i_buffer) 33 | { 34 | this._ref_bitmap = i_buffer; 35 | } 36 | ,getPixel : function(i_x, i_y, o_rgb) 37 | { 38 | var c = this._ref_bitmap.getPixel(i_x, i_y); 39 | o_rgb[0] = (c >> 16) & 0xff;// R 40 | o_rgb[1] = (c >> 8) & 0xff;// G 41 | o_rgb[2] = c & 0xff;// B 42 | return; 43 | } 44 | ,getPixelSet : function(i_x, i_y, i_num, o_rgb) 45 | { 46 | var bmp = this._ref_bitmap; 47 | var c; 48 | var i; 49 | for (i = 0; i < i_num; i++) { 50 | c = bmp.getPixel(i_x[i], i_y[i]); 51 | o_rgb[i*3+0] = (c >> 16) & 0xff; 52 | o_rgb[i*3+1] = (c >> 8) & 0xff; 53 | o_rgb[i*3+2] = c & 0xff; 54 | } 55 | } 56 | ,setPixel : function(i_x, i_y, i_rgb) 57 | { 58 | NyARException.notImplement(); 59 | } 60 | ,setPixels : function(i_x, i_y, i_num, i_intrgb) 61 | { 62 | NyARException.notImplement(); 63 | } 64 | ,switchBuffer : function(i_ref_buffer) 65 | { 66 | NyARException.notImplement(); 67 | } 68 | }) 69 | FLARGrayPixelReader_BitmapData = ASKlass('FLARGrayPixelReader_BitmapData', 70 | { 71 | _ref_bitmap : null 72 | ,FLARGrayPixelReader_BitmapData : function(i_buffer) 73 | { 74 | this._ref_bitmap = i_buffer; 75 | } 76 | ,getPixel : function(i_x, i_y, i_num, o_gray) 77 | { 78 | NyARException.notImplement(); 79 | var w = this._ref_bitmap.getWidth(); 80 | var d = this._ref_bitmap.getBuffer(); 81 | o_gray[0] = o_gray[1] = o_gray[2] = ~d(i_x + w*i_y) & 0xff; 82 | } 83 | ,getPixelSet : function(i_x, i_y, i_num, o_gray) 84 | { 85 | var w = this._ref_bitmap.getWidth(); 86 | var d = this._ref_bitmap.data; 87 | for (var i = 0; i < i_num; i++) { 88 | o_gray[i] = ~d[i_x[i] + w*i_y[i]] & 0xff; 89 | } 90 | } 91 | ,setPixel : function(i_x, i_y, i_rgb) 92 | { 93 | NyARException.notImplement(); 94 | } 95 | ,setPixels : function(i_x, i_y, i_num, i_intrgb) 96 | { 97 | NyARException.notImplement(); 98 | } 99 | ,switchBuffer : function(i_ref_buffer) 100 | { 101 | NyARException.notImplement(); 102 | } 103 | }) -------------------------------------------------------------------------------- /src/FLARSquareDetect.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | FLARSquare = NyARSquare; 30 | Cxdir = new IntVector([0,1,1,1,0,-1,-1,-1]); 31 | Cydir = new IntVector([-1,-1,0,1,1,1,0,-1]); 32 | FLContourPickup = ASKlass('FLContourPickup', NyARContourPickup, 33 | { 34 | FLContourPickup : function() 35 | { 36 | } 37 | ,getContour_FLARBinRaster : function(i_raster,i_entry_x,i_entry_y,i_array_size,o_coord_x,o_coord_y) 38 | { 39 | var xdir = this._getContour_xdir;// static int xdir[8] = { 0, 1, 1, 1, 0,-1,-1,-1}; 40 | var ydir = this._getContour_ydir;// static int ydir[8] = {-1,-1, 0, 1, 1, 1, 0,-1}; 41 | var i_buf=i_raster.getBuffer(); 42 | var width=i_raster.getWidth(); 43 | var height=i_raster.getHeight(); 44 | //クリップ領域の上端に接しているポイントを得る。 45 | var coord_num = 1; 46 | o_coord_x[0] = i_entry_x; 47 | o_coord_y[0] = i_entry_y; 48 | var dir = 5; 49 | var c = i_entry_x; 50 | var r = i_entry_y; 51 | for (;;) { 52 | dir = (dir + 5) % 8;//dirの正規化 53 | //ここは頑張ればもっと最適化できると思うよ。 54 | //4隅以外の境界接地の場合に、境界チェックを省略するとかね。 55 | if(c>=1 && c=1 && r0) { 59 | break; 60 | } 61 | dir++; 62 | if (i_buf.getPixel(c + xdir[dir], r + ydir[dir]) >0) { 63 | break; 64 | } 65 | dir++; 66 | if (i_buf.getPixel(c + xdir[dir], r + ydir[dir]) >0) { 67 | break; 68 | } 69 | dir++; 70 | if (i_buf.getPixel(c + xdir[dir], r + ydir[dir]) >0) { 71 | break; 72 | } 73 | dir++; 74 | if (i_buf.getPixel(c + xdir[dir], r + ydir[dir]) >0) { 75 | break; 76 | } 77 | dir++; 78 | if (i_buf.getPixel(c + xdir[dir], r + ydir[dir]) >0) { 79 | break; 80 | } 81 | dir++; 82 | if (i_buf.getPixel(c + xdir[dir], r + ydir[dir]) >0) { 83 | break; 84 | } 85 | dir++; 86 | if (i_buf.getPixel(c + xdir[dir], r + ydir[dir]) >0) { 87 | break; 88 | } 89 | //8方向全て調べたけどラベルが無いよ? 90 | return -1; 91 | } 92 | }else{ 93 | //境界に接しているとき 94 | var i; 95 | for (i = 0; i < 8; i++){ 96 | var x=c + xdir[dir]; 97 | var y=r + ydir[dir]; 98 | //境界チェック 99 | if(x>=0 && x=0 && y0) { 101 | break; 102 | } 103 | } 104 | dir++;//倍長テーブルを参照するので問題なし 105 | } 106 | if (i == 8) { 107 | //8方向全て調べたけどラベルが無いよ? 108 | return -1; 109 | } 110 | } 111 | dir=dir% 8;//dirの正規化 112 | // xcoordとycoordをc,rにも保存 113 | c = c + xdir[dir]; 114 | r = r + ydir[dir]; 115 | o_coord_x[coord_num] = c; 116 | o_coord_y[coord_num] = r; 117 | // 終了条件判定 118 | if (c == i_entry_x && r == i_entry_y){ 119 | coord_num++; 120 | break; 121 | } 122 | coord_num++; 123 | if (coord_num == i_array_size) { 124 | //輪郭が末端に達した 125 | return coord_num; 126 | } 127 | } 128 | return coord_num; 129 | } 130 | }) 131 | 132 | FLARSquareContourDetector = ASKlass('FLARSquareContourDetector', NyARSquareContourDetector, 133 | { 134 | AR_AREA_MAX : 100000// #define AR_AREA_MAX 100000 135 | ,AR_AREA_MIN : 70// #define AR_AREA_MIN 70 136 | ,_width : 0 137 | ,_height : 0 138 | ,_labeling : null 139 | ,_overlap_checker : new NyARLabelOverlapChecker(32) 140 | ,_cpickup : new FLContourPickup() 141 | ,_stack : null 142 | ,_coord2vertex : new NyARCoord2SquareVertexIndexes() 143 | ,_max_coord : 0 144 | ,_xcoord : null 145 | ,_ycoord : null 146 | /** 147 | * 最大i_squre_max個のマーカーを検出するクラスを作成する。 148 | * 149 | * @param i_param 150 | */ 151 | ,FLARSquareContourDetector : function(i_size) 152 | { 153 | this._width = i_size.w; 154 | this._height = i_size.h; 155 | //ラベリングのサイズを指定したいときはsetAreaRangeを使ってね。 156 | this._labeling = new NyARLabeling_Rle(this._width,this._height); 157 | this._stack=new NyARRleLabelFragmentInfoStack(i_size.w*i_size.h*2048/(320*240)+32);//検出可能な最大ラベル数 158 | // 輪郭の最大長は画面に映りうる最大の長方形サイズ。 159 | var number_of_coord= (this._width + this._height) * 2; 160 | // 輪郭バッファ 161 | this._max_coord = number_of_coord; 162 | this._xcoord = new IntVector(number_of_coord); 163 | this._ycoord = new IntVector(number_of_coord); 164 | return; 165 | } 166 | /** 167 | * 白領域の検査対象サイズ 168 | * 最大サイズは 一辺約320px、最小サイズは 一辺約 8px まで解析対象としている 169 | * 解析画像中で上記範囲内であれば解析対象となるが、最小サイズは小さすぎて意味をなさない。 170 | * 171 | * @param i_max 解析対象とする白領域の最大pixel数(一辺の二乗) 172 | * @param i_min 解析対象とする白領域の最小pixel数(一辺の二乗) 173 | */ 174 | ,setAreaRange : function(i_max, i_min) 175 | { 176 | this._labeling.setAreaRange(i_max, i_min); 177 | } 178 | ,__detectMarker_mkvertex : new IntVector(4) 179 | ,detectMarkerCB : function(i_raster ,i_callback) 180 | { 181 | var flagment=this._stack; 182 | var overlap = this._overlap_checker; 183 | // ラベル数が0ならここまで 184 | var label_num=this._labeling.labeling(i_raster, flagment); 185 | if (label_num < 1) { 186 | return; 187 | } 188 | //ラベルをソートしておく 189 | flagment.sortByArea(); 190 | //ラベルリストを取得 191 | var labels=flagment.getArray(); 192 | var xsize = this._width; 193 | var ysize = this._height; 194 | var xcoord = this._xcoord; 195 | var ycoord = this._ycoord; 196 | var coord_max = this._max_coord; 197 | var mkvertex =this.__detectMarker_mkvertex; 198 | //重なりチェッカの最大数を設定 199 | overlap.setMaxLabels(label_num); 200 | for (var i=0; i < label_num; i++) { 201 | var label_pt=labels[i]; 202 | var label_area = label_pt.area; 203 | // クリップ領域が画面の枠に接していれば除外 204 | if (label_pt.clip_l == 0 || label_pt.clip_r == xsize-1){ 205 | continue; 206 | } 207 | if (label_pt.clip_t == 0 || label_pt.clip_b == ysize-1){ 208 | continue; 209 | } 210 | // 既に検出された矩形との重なりを確認 211 | if (!overlap.check(label_pt)) { 212 | // 重なっているようだ。 213 | continue; 214 | } 215 | if (window.DEBUG) { 216 | var cv = document.getElementById('debugCanvas').getContext('2d'); 217 | cv.strokeStyle = 'red'; 218 | cv.strokeRect(label_pt.clip_l, label_pt.clip_t, label_pt.clip_r-label_pt.clip_l, label_pt.clip_b-label_pt.clip_t); 219 | cv.fillStyle = 'red'; 220 | cv.fillRect(label_pt.entry_x-1, label_pt.clip_t-1, 3,3); 221 | cv.fillStyle = 'cyan'; 222 | cv.fillRect(label_pt.pos_x-1, label_pt.pos_y-1, 3,3); 223 | } 224 | //輪郭を取得 225 | var coord_num = this._cpickup.getContour_FLARBinRaster(i_raster,label_pt.entry_x,label_pt.clip_t, coord_max, xcoord, ycoord); 226 | if (coord_num == -1) return -1; 227 | if (coord_num == coord_max) { 228 | // 輪郭が大きすぎる。 229 | continue; 230 | } 231 | //輪郭線をチェックして、矩形かどうかを判定。矩形ならばmkvertexに取得 232 | var v = this._coord2vertex.getVertexIndexes(xcoord, ycoord,coord_num,label_area, mkvertex); 233 | if (!v) { 234 | // 頂点の取得が出来なかった 235 | continue; 236 | } 237 | //矩形を発見したことをコールバック関数で通知 238 | i_callback.onSquareDetect(this,xcoord,ycoord,coord_num,mkvertex); 239 | // 検出済の矩形の属したラベルを重なりチェックに追加する。 240 | overlap.push(label_pt); 241 | } 242 | return; 243 | } 244 | }) 245 | 246 | -------------------------------------------------------------------------------- /src/FLARTransMat.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | FLARTransMatResult = NyARTransMatResult; 30 | -------------------------------------------------------------------------------- /src/FLARTypes.js: -------------------------------------------------------------------------------- 1 | /* 2 | * PROJECT: FLARToolKit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the NyARToolKit developed by 5 | * R.Iizuka (nyatla) 6 | * http://nyatla.jp/nyatoolkit/ 7 | * 8 | * The FLARToolKit is ActionScript 3.0 version ARToolkit class library. 9 | * Copyright (C)2008 Saqoosha 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | * 24 | * For further information please contact. 25 | * http://www.libspark.org/wiki/saqoosha/FLARToolKit 26 | * 27 | * 28 | */ 29 | FLARDoublePoint2d = NyARDoublePoint2d; 30 | FLARDoublePoint3d = NyARDoublePoint3d; 31 | FLARIntSize = NyARIntSize; 32 | -------------------------------------------------------------------------------- /src/NyARCode.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | 34 | 35 | NyARMatchPattDeviationBlackWhiteData = ASKlass('NyARMatchPattDeviationBlackWhiteData', 36 | { 37 | _data : null, 38 | _pow : 0, 39 | // 40 | _number_of_pixels : 0, 41 | refData : function() 42 | { 43 | return this._data; 44 | } 45 | ,getPow : function() 46 | { 47 | return this._pow; 48 | } 49 | ,NyARMatchPattDeviationBlackWhiteData : function(i_width,i_height) 50 | { 51 | this._number_of_pixels=i_height*i_width; 52 | this._data=new IntVector(this._number_of_pixels); 53 | return; 54 | } 55 | /** 56 | * XRGB[width*height]の配列から、パターンデータを構築。 57 | * @param i_buffer 58 | */ 59 | ,setRaster : function(i_raster) 60 | { 61 | //i_buffer[XRGB]→差分[BW]変換 62 | var i; 63 | var ave;// 64 | var rgb;// 65 | var linput=this._data;// 66 | var buf=(i_raster.getBuffer()); 67 | // input配列のサイズとwhも更新// input=new int[height][width][3]; 68 | var number_of_pixels=this._number_of_pixels; 69 | //<平均値計算(FORの1/8展開)/> 70 | ave = 0; 71 | for(i=number_of_pixels-1;i>=0;i--){ 72 | rgb = buf[i]; 73 | ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); 74 | } 75 | ave=(number_of_pixels*255*3-ave)/(3*number_of_pixels); 76 | // 77 | var sum = 0,w_sum; 78 | //<差分値計算/> 79 | for (i = number_of_pixels-1; i >= 0;i--) { 80 | rgb = buf[i]; 81 | w_sum =((255*3-(rgb & 0xff)-((rgb >> 8) & 0xff)-((rgb >> 16) & 0xff))/3)-ave; 82 | linput[i] = w_sum; 83 | sum += w_sum * w_sum; 84 | } 85 | var p=Math.sqrt(sum); 86 | this._pow=p!=0.0?p:0.0000001; 87 | return; 88 | } 89 | }) 90 | NyARMatchPattDeviationColorData = ASKlass('NyARMatchPattDeviationColorData', 91 | { 92 | _data : null, 93 | _pow : 0, 94 | // 95 | _number_of_pixels : 0, 96 | _optimize_for_mod : 0, 97 | refData : function() 98 | { 99 | return this._data; 100 | } 101 | ,getPow : function() 102 | { 103 | return this._pow; 104 | } 105 | ,NyARMatchPattDeviationColorData : function(i_width,i_height) 106 | { 107 | this._number_of_pixels=i_height*i_width; 108 | this._data=new IntVector(this._number_of_pixels*3); 109 | this._optimize_for_mod=this._number_of_pixels-(this._number_of_pixels%8); 110 | return; 111 | } 112 | /** 113 | * NyARRasterからパターンデータをセットします。 114 | * この関数は、データを元に所有するデータ領域を更新します。 115 | * @param i_buffer 116 | */ 117 | ,setRaster : function(i_raster) 118 | { 119 | //画素フォーマット、サイズ制限 120 | NyAS3Utils.assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32)); 121 | NyAS3Utils.assert(i_raster.getSize().isEqualSize_NyARIntSize(i_raster.getSize())); 122 | var buf=(i_raster.getBuffer()); 123 | //i_buffer[XRGB]→差分[R,G,B]変換 124 | var i; 125 | var ave;// 126 | var rgb;// 127 | var linput=this._data;// 128 | // input配列のサイズとwhも更新// input=new int[height][width][3]; 129 | var number_of_pixels=this._number_of_pixels; 130 | var for_mod=this._optimize_for_mod; 131 | //<平均値計算(FORの1/8展開)> 132 | ave = 0; 133 | for(i=number_of_pixels-1;i>=for_mod;i--){ 134 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); 135 | } 136 | for (;i>=0;) { 137 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);i--; 138 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);i--; 139 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);i--; 140 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);i--; 141 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);i--; 142 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);i--; 143 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);i--; 144 | rgb = buf[i];ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);i--; 145 | } 146 | //<平均値計算(FORの1/8展開)/> 147 | ave=number_of_pixels*255*3-ave; 148 | ave =255-(ave/ (number_of_pixels * 3));//(255-R)-ave を分解するための事前計算 149 | var sum = 0,w_sum; 150 | var input_ptr=number_of_pixels*3-1; 151 | //<差分値計算(FORの1/8展開)> 152 | for (i = number_of_pixels-1; i >= for_mod;i--) { 153 | rgb = buf[i]; 154 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 155 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 156 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 157 | } 158 | for (; i >=0;) { 159 | rgb = buf[i];i--; 160 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 161 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 162 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 163 | rgb = buf[i];i--; 164 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 165 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 166 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 167 | rgb = buf[i];i--; 168 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 169 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 170 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 171 | rgb = buf[i];i--; 172 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 173 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 174 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 175 | rgb = buf[i];i--; 176 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 177 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 178 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 179 | rgb = buf[i];i--; 180 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 181 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 182 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 183 | rgb = buf[i];i--; 184 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 185 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 186 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 187 | rgb = buf[i];i--; 188 | w_sum = (ave - (rgb & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//B 189 | w_sum = (ave - ((rgb >> 8) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//G 190 | w_sum = (ave - ((rgb >> 16) & 0xff)) ;linput[input_ptr--] = w_sum;sum += w_sum * w_sum;//R 191 | } 192 | //<差分値計算(FORの1/8展開)/> 193 | var p=Math.sqrt(sum); 194 | this._pow=p!=0.0?p:0.0000001; 195 | return; 196 | } 197 | }) 198 | NyARMatchPattResult = ASKlass('NyARMatchPattResult', 199 | { 200 | DIRECTION_UNKNOWN : -1, 201 | confidence : 0, 202 | direction : 0 203 | }) 204 | 205 | 206 | 207 | /** 208 | * ARToolKitのマーカーコードを1個保持します。 209 | * 210 | */ 211 | NyARCode = ASKlass('NyARCode', 212 | { 213 | _color_pat : new Array(4), 214 | _bw_pat : new Array(4), 215 | _width : 0, 216 | _height : 0, 217 | NyARCode : function(i_width, i_height) 218 | { 219 | this._width = i_width; 220 | this._height = i_height; 221 | //空のラスタを4個作成 222 | for(var i=0;i<4;i++){ 223 | this._color_pat[i]=new NyARMatchPattDeviationColorData(i_width,i_height); 224 | this._bw_pat[i]=new NyARMatchPattDeviationBlackWhiteData(i_width,i_height); 225 | } 226 | return; 227 | } 228 | ,getColorData : function(i_index) 229 | { 230 | return this._color_pat[i_index]; 231 | } 232 | ,getBlackWhiteData : function(i_index) 233 | { 234 | return this._bw_pat[i_index]; 235 | } 236 | ,getWidth : function() 237 | { 238 | return this._width; 239 | } 240 | ,getHeight : function() 241 | { 242 | return this._height; 243 | } 244 | ,loadARPattFromFile : function(i_stream) 245 | { 246 | NyARCodeFileReader.loadFromARToolKitFormFile(i_stream,this); 247 | return; 248 | } 249 | ,setRaster : function(i_raster) 250 | { 251 | NyAS3Utils.assert(i_raster.length!=4); 252 | //ラスタにパターンをロードする。 253 | for(var i=0;i<4;i++){ 254 | this._color_pat[i].setRaster(i_raster[i]); 255 | } 256 | return; 257 | } 258 | }) 259 | 260 | 261 | 262 | 263 | 264 | 265 | NyARCodeFileReader = ASKlass('NyARCodeFileReader', 266 | { 267 | 268 | /** 269 | * ARコードファイルからデータを読み込んでo_codeに格納します。 270 | * @param i_stream 271 | * @param o_code 272 | * @throws NyARException 273 | */ 274 | loadFromARToolKitFormFile : function(i_stream,o_code) 275 | { 276 | var width=o_code.getWidth(); 277 | var height=o_code.getHeight(); 278 | var tmp_raster=new NyARRaster(width,height,NyARBufferType.INT1D_X8R8G8B8_32); 279 | //4個の要素をラスタにセットする。 280 | var token = i_stream.match(/\d+/g); 281 | var buf=(tmp_raster.getBuffer()); 282 | //GBRAで一度読みだす。 283 | for (var h = 0; h < 4; h++){ 284 | this.readBlock(token,width,height,buf); 285 | //ARCodeにセット(カラー) 286 | o_code.getColorData(h).setRaster(tmp_raster); 287 | o_code.getBlackWhiteData(h).setRaster(tmp_raster); 288 | } 289 | tmp_raster=null;//ポイ 290 | return; 291 | } 292 | /** 293 | * 1ブロック分のXRGBデータをi_stからo_bufへ読みだします。 294 | * @param i_st 295 | * @param o_buf 296 | */ 297 | ,readBlock : function(i_st, i_width, i_height, o_buf) 298 | { 299 | var pixels = i_width * i_height; 300 | var i3; 301 | for (i3 = 0; i3 < 3; i3++) { 302 | for (var i2 = 0; i2 < pixels; i2++){ 303 | // 数値のみ読み出す 304 | var val = parseInt(i_st.shift()); 305 | if(isNaN(val)){ 306 | throw new NyARException("syntax error in pattern file."); 307 | } 308 | o_buf[i2]=(o_buf[i2]<<8)|((0x000000ff&toInt(val))); 309 | } 310 | } 311 | //GBR→RGB 312 | for(i3=0;i3>16)&0x0000ff); 314 | } 315 | return; 316 | } 317 | }) 318 | -------------------------------------------------------------------------------- /src/NyARHistogramAnalyzer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | INyARHistogramAnalyzer_Threshold = ASKlass('INyARHistogramAnalyzer_Threshold', 34 | { 35 | getThreshold : function(i_histgram){} 36 | }) 37 | NyARHistogramAnalyzer_SlidePTile = ASKlass('NyARHistogramAnalyzer_SlidePTile', INyARHistogramAnalyzer_Threshold, 38 | { 39 | _persentage : 0, 40 | NyARHistogramAnalyzer_SlidePTile : function(i_persentage) 41 | { 42 | NyAS3Utils.assert (0 <= i_persentage && i_persentage <= 50); 43 | //初期化 44 | this._persentage=i_persentage; 45 | } 46 | ,getThreshold : function(i_histgram) 47 | { 48 | //総ピクセル数を計算 49 | var n=i_histgram.length; 50 | var sum_of_pixel=i_histgram.total_of_data; 51 | var hist=i_histgram.data; 52 | // 閾値ピクセル数確定 53 | var th_pixcels = sum_of_pixel * this._persentage / 100; 54 | var th_wk; 55 | var th_w, th_b; 56 | // 黒点基準 57 | th_wk = th_pixcels; 58 | for (th_b = 0; th_b < n-2; th_b++) { 59 | th_wk -= hist[th_b]; 60 | if (th_wk <= 0) { 61 | break; 62 | } 63 | } 64 | // 白点基準 65 | th_wk = th_pixcels; 66 | for (th_w = n-1; th_w > 1; th_w--) { 67 | th_wk -= hist[th_w]; 68 | if (th_wk <= 0) { 69 | break; 70 | } 71 | } 72 | // 閾値の保存 73 | return (th_w + th_b) / 2; 74 | } 75 | }) 76 | -------------------------------------------------------------------------------- /src/NyARMatch.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | 34 | /** 35 | * ARColorPattのマッチング計算をするインタフェイスです。 基準Patに対して、計算済みのARCodeデータとの間で比較演算をします。 36 | * pattern_match関数を分解した3種類のパターン検出クラスを定義します。 37 | * 38 | */ 39 | INyARMatchPatt = ASKlass('INyARMatchPatt', 40 | { 41 | setARCode : function(i_code){} 42 | }) 43 | NyARMatchPatt_Color_WITHOUT_PCA = ASKlass('NyARMatchPatt_Color_WITHOUT_PCA', INyARMatchPatt, 44 | { 45 | _code_patt : null, 46 | _optimize_for_mod : 0, 47 | _rgbpixels : 0, 48 | NyARMatchPatt_Color_WITHOUT_PCA : function() 49 | { 50 | switch(arguments.length){ 51 | case 1: 52 | { //,NyARMatchPatt_Color_WITHOUT_PCA : function(i_code_ref) 53 | var i_code_ref=arguments[0]; 54 | var w=i_code_ref.getWidth(); 55 | var h=i_code_ref.getHeight(); 56 | //最適化定数の計算 57 | this._rgbpixels=w*h*3; 58 | this._optimize_for_mod=this._rgbpixels-(this._rgbpixels%16); 59 | this.setARCode(i_code_ref); 60 | return; 61 | } 62 | break; 63 | case 2: 64 | { //,NyARMatchPatt_Color_WITHOUT_PCA : function(i_width,i_height) 65 | var i_width = toInt(arguments[0]), i_height = toInt(arguments[1]); 66 | //最適化定数の計算 67 | this._rgbpixels=i_height*i_width*3; 68 | this._optimize_for_mod=this._rgbpixels-(this._rgbpixels%16); 69 | return; 70 | } 71 | break; 72 | default: 73 | break; 74 | } 75 | throw new NyARException(); 76 | } 77 | /** 78 | * 比較対象のARCodeをセットします。 79 | * @throws NyARException 80 | */ 81 | ,setARCode : function(i_code_ref) 82 | { 83 | this._code_patt=i_code_ref; 84 | return; 85 | } 86 | /** 87 | * 現在セットされているARコードとi_pattを比較します。 88 | */ 89 | ,evaluate : function(i_patt,o_result) 90 | { 91 | NyAS3Utils.assert(this._code_patt!=null); 92 | // 93 | var linput = i_patt.refData(); 94 | var sum; 95 | var max = Number.MIN_VALUE; 96 | var res = NyARMatchPattResult.DIRECTION_UNKNOWN; 97 | var for_mod=this._optimize_for_mod; 98 | for (var j = 0; j < 4; j++) { 99 | //合計値初期化 100 | sum=0; 101 | var code_patt=this._code_patt.getColorData(j); 102 | var pat_j = code_patt.refData(); 103 | //<全画素について、比較(FORの1/16展開)> 104 | var i; 105 | for(i=this._rgbpixels-1;i>=for_mod;i--){ 106 | sum += linput[i] * pat_j[i]; 107 | } 108 | for (;i>=0;) { 109 | sum += linput[i] * pat_j[i];i--; 110 | sum += linput[i] * pat_j[i];i--; 111 | sum += linput[i] * pat_j[i];i--; 112 | sum += linput[i] * pat_j[i];i--; 113 | sum += linput[i] * pat_j[i];i--; 114 | sum += linput[i] * pat_j[i];i--; 115 | sum += linput[i] * pat_j[i];i--; 116 | sum += linput[i] * pat_j[i];i--; 117 | sum += linput[i] * pat_j[i];i--; 118 | sum += linput[i] * pat_j[i];i--; 119 | sum += linput[i] * pat_j[i];i--; 120 | sum += linput[i] * pat_j[i];i--; 121 | sum += linput[i] * pat_j[i];i--; 122 | sum += linput[i] * pat_j[i];i--; 123 | sum += linput[i] * pat_j[i];i--; 124 | sum += linput[i] * pat_j[i];i--; 125 | } 126 | //<全画素について、比較(FORの1/16展開)/> 127 | var sum2 = sum / code_patt.getPow();// sum2 = sum / patpow[k][j]/ datapow; 128 | if (sum2 > max) { 129 | max = sum2; 130 | res = j; 131 | } 132 | } 133 | o_result.direction = res; 134 | o_result.confidence= max/i_patt.getPow(); 135 | return true; 136 | } 137 | }) 138 | -------------------------------------------------------------------------------- /src/NyARPca2d.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | INyARPca2d = ASKlass('INyARPca2d', 34 | { 35 | /** 36 | * 通常のPCA 37 | * @param i_v1 38 | * @param i_v2 39 | * @param i_start 40 | * @param i_number_of_point 41 | * @param o_evec 42 | * 要素2の変数を指定してください。 43 | * @param o_ev 44 | * 要素2の変数を指定してください。 45 | * @param o_mean 46 | * @throws NyARException 47 | */ 48 | pca : function(i_v1, i_v2, i_number_of_point, o_evec, o_ev, o_mean){} 49 | }) 50 | NyARPca2d_MatrixPCA_O2 = ASKlass('NyARPca2d_MatrixPCA_O2', INyARPca2d, 51 | { 52 | PCA_EPS : 1e-6, // #define EPS 1e-6 53 | PCA_MAX_ITER : 100, // #define MAX_ITER 100 54 | PCA_VZERO : 1e-16, // #define VZERO 1e-16 55 | /** 56 | * static int QRM( ARMat *a, ARVec *dv )の代替関数 57 | * 58 | * @param a 59 | * @param dv 60 | * @throws NyARException 61 | */ 62 | PCA_QRM : function(o_matrix,dv) 63 | { 64 | var w, t, s, x, y, c; 65 | var ev1; 66 | var dv_x,dv_y; 67 | var mat00,mat01,mat10,mat11; 68 | // 69 | dv_x = o_matrix.m00;// this.m[dim - 2][dim - 2];// d.v[dim-2]=a.m[dim-2][dim-2];//d->v[dim-2]=a->m[(dim-2)*dim+(dim-2)]; 70 | ev1 = o_matrix.m01;// this.m[dim - 2][dim - 1];// e.v[dim-2+i_e_start]=a.m[dim-2][dim-1];//e->v[dim-2] = a->m[(dim-2)*dim+(dim-1)]; 71 | dv_y = o_matrix.m11;// this.m[dim - 1][dim - 1];// d.v[dim-1]=a_array[dim-1][dim-1];//d->v[dim-1] =a->m[(dim-1)*dim+(dim-1)]; 72 | // 単位行列にする。 73 | mat00 = mat11 = 1; 74 | mat01 = mat10 = 0; 75 | // 76 | // int j = 1; 77 | // // while(j>0 && fabs(ev->v[j])>EPS*(fabs(dv->v[j-1])+fabs(dv->v[j]))) 78 | // while (j > 0 && Math.abs(ev1) > PCA_EPS * (Math.abs(dv.x) + Math.abs(dv.y))) { 79 | // j--; 80 | // } 81 | // if (j == 0) { 82 | var iter = 0; 83 | do { 84 | iter++; 85 | if (iter > this.PCA_MAX_ITER) { 86 | break; 87 | } 88 | w = (dv_x - dv_y) / 2;// w = (dv->v[h-1] -dv->v[h]) / 2;//ここ? 89 | t = ev1 * ev1;// t = ev->v[h] * ev->v[h]; 90 | s = Math.sqrt(w * w + t); 91 | if (w < 0) { 92 | s = -s; 93 | } 94 | x = dv_x - dv_y + t / (w + s);// x = dv->v[j] -dv->v[h] +t/(w+s); 95 | y = ev1;// y = ev->v[j+1]; 96 | if (Math.abs(x) >= Math.abs(y)) { 97 | if (Math.abs(x) > this.PCA_VZERO) { 98 | t = -y / x; 99 | c = 1 / Math.sqrt(t * t + 1); 100 | s = t * c; 101 | } else { 102 | c = 1.0; 103 | s = 0.0; 104 | } 105 | } else { 106 | t = -x / y; 107 | s = 1.0 / Math.sqrt(t * t + 1); 108 | c = t * s; 109 | } 110 | w = dv_x - dv_y;// w = dv->v[k] -dv->v[k+1]; 111 | t = (w * s + 2 * c * ev1) * s;// t = (w * s +2 * c *ev->v[k+1]) *s; 112 | dv_x -= t;// dv->v[k] -= t; 113 | dv_y += t;// dv->v[k+1] += t; 114 | ev1 += s * (c * w - 2 * s * ev1);// ev->v[k+1]+= s * (c* w- 2* s *ev->v[k+1]); 115 | x = mat00;// x = a->m[k*dim+i]; 116 | y = mat10;// y = a->m[(k+1)*dim+i]; 117 | mat00 = c * x - s * y;// a->m[k*dim+i] = c * x - s* y; 118 | mat10 = s * x + c * y;// a->m[(k+1)*dim+i] = s* x + c * y; 119 | x = mat01;// x = a->m[k*dim+i]; 120 | y = mat11;// y = a->m[(k+1)*dim+i]; 121 | mat01 = c * x - s * y;// a->m[k*dim+i] = c * x - s* y; 122 | mat11 = s * x + c * y;// a->m[(k+1)*dim+i] = s* x + c * y; 123 | } while (Math.abs(ev1) > this.PCA_EPS * (Math.abs(dv_x) + Math.abs(dv_y))); 124 | // } 125 | t = dv_x;// t = dv->v[h]; 126 | if (dv_y > t) {// if( dv->v[i] > t ) { 127 | t = dv_y;// t = dv->v[h]; 128 | dv_y = dv_x;// dv->v[h] = dv->v[k]; 129 | dv_x = t;// dv->v[k] = t; 130 | // 行の入れ替え 131 | o_matrix.m00 = mat10; 132 | o_matrix.m01 = mat11; 133 | o_matrix.m10 = mat00; 134 | o_matrix.m11 = mat01; 135 | } else { 136 | // 行の入れ替えはなし 137 | o_matrix.m00 = mat00; 138 | o_matrix.m01 = mat01; 139 | o_matrix.m10 = mat10; 140 | o_matrix.m11 = mat11; 141 | } 142 | dv[0]=dv_x; 143 | dv[1]=dv_y; 144 | return; 145 | } 146 | /** 147 | * static int PCA( ARMat *input, ARMat *output, ARVec *ev ) 148 | * 149 | * @param output 150 | * @param o_ev 151 | * @throws NyARException 152 | */ 153 | ,PCA_PCA : function(i_v1,i_v2,i_number_of_data,o_matrix,o_ev,o_mean) 154 | { 155 | var i; 156 | // double[] mean_array=mean.getArray(); 157 | // mean.zeroClear(); 158 | //PCA_EXの処理 159 | var sx = 0; 160 | var sy = 0; 161 | for (i = 0; i < i_number_of_data; i++) { 162 | sx += i_v1[i]; 163 | sy += i_v2[i]; 164 | } 165 | sx = sx / i_number_of_data; 166 | sy = sy / i_number_of_data; 167 | //PCA_CENTERとPCA_xt_by_xを一緒に処理 168 | var srow = Math.sqrt((i_number_of_data)); 169 | var w00, w11, w10; 170 | w00 = w11 = w10 = 0.0;// *out = 0.0; 171 | for (i = 0; i < i_number_of_data; i++) { 172 | var x = (i_v1[i] - sx) / srow; 173 | var y = (i_v2[i] - sy) / srow; 174 | w00 += (x * x);// *out += *in1 * *in2; 175 | w10 += (x * y);// *out += *in1 * *in2; 176 | w11 += (y * y);// *out += *in1 * *in2; 177 | } 178 | o_matrix.m00=w00; 179 | o_matrix.m01=o_matrix.m10=w10; 180 | o_matrix.m11=w11; 181 | //PCA_PCAの処理 182 | this.PCA_QRM(o_matrix, o_ev); 183 | // m2 = o_output.m;// m2 = output->m; 184 | if (o_ev[0] < this.PCA_VZERO) {// if( ev->v[i] < VZERO ){ 185 | o_ev[0] = 0.0;// ev->v[i] = 0.0; 186 | o_matrix.m00 = 0.0;// *(m2++) = 0.0; 187 | o_matrix.m01 = 0.0;// *(m2++) = 0.0; 188 | } 189 | if (o_ev[1] < this.PCA_VZERO) {// if( ev->v[i] < VZERO ){ 190 | o_ev[1] = 0.0;// ev->v[i] = 0.0; 191 | o_matrix.m10 = 0.0;// *(m2++) = 0.0; 192 | o_matrix.m11 = 0.0;// *(m2++) = 0.0; 193 | } 194 | o_mean[0]=sx; 195 | o_mean[1]=sy; 196 | // } 197 | return; 198 | } 199 | ,pca : function(i_v1,i_v2,i_number_of_point,o_evec,o_ev,o_mean) 200 | { 201 | this.PCA_PCA(i_v1,i_v2,i_number_of_point,o_evec, o_ev,o_mean); 202 | var sum = o_ev[0] + o_ev[1]; 203 | // For順変更禁止 204 | o_ev[0] /= sum;// ev->v[i] /= sum; 205 | o_ev[1] /= sum;// ev->v[i] /= sum; 206 | return; 207 | } 208 | }) 209 | -------------------------------------------------------------------------------- /src/NyARRaster.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | 34 | INyARRaster = ASKlass('INyARRaster', 35 | { 36 | getWidth : function(){}, 37 | getHeight : function(){}, 38 | getSize : function(){}, 39 | /** 40 | * バッファオブジェクトを返します。 41 | * @return 42 | */ 43 | getBuffer : function(){}, 44 | /** 45 | * バッファオブジェクトのタイプを返します。 46 | * @return 47 | */ 48 | getBufferType : function(){}, 49 | /** 50 | * バッファのタイプがi_type_valueであるか、チェックします。 51 | * この値は、NyARBufferTypeに定義された定数値です。 52 | * @param i_type_value 53 | * @return 54 | */ 55 | isEqualBufferType : function(i_type_value){}, 56 | /** 57 | * getBufferがオブジェクトを返せるかの真偽値です。 58 | * @return 59 | */ 60 | hasBuffer : function(){}, 61 | /** 62 | * i_ref_bufをラップします。できる限り整合性チェックを行います。 63 | * バッファの再ラッピングが可能な関数のみ、この関数を実装してください。 64 | * @param i_ref_buf 65 | */ 66 | wrapBuffer : function(i_ref_buf){} 67 | }) 68 | 69 | NyARRaster_BasicClass = ASKlass('NyARRaster_BasicClass', INyARRaster, 70 | { 71 | _size : null, 72 | _buffer_type : 0, 73 | /* 74 | * ,NyARRaster_BasicClass : function(int i_width,int i_height,int i_buffer_type) 75 | */ 76 | NyARRaster_BasicClass : function() 77 | { 78 | switch(arguments.length) { 79 | case 1: 80 | if (arguments[0] == NyAS3Const_Inherited) { 81 | //blank 82 | } 83 | break; 84 | case 3: 85 | this.overload_NyARRaster_BasicClass(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2])); 86 | break; 87 | default: 88 | throw new NyARException(); 89 | } 90 | } 91 | ,overload_NyARRaster_BasicClass : function(i_width ,i_height,i_buffer_type) 92 | { 93 | this._size = new NyARIntSize(i_width, i_height); 94 | this._buffer_type=i_buffer_type; 95 | } 96 | ,getWidth : function() 97 | { 98 | return this._size.w; 99 | } 100 | ,getHeight : function() 101 | { 102 | return this._size.h; 103 | } 104 | ,getSize : function() 105 | { 106 | return this._size; 107 | } 108 | ,getBufferType : function() 109 | { 110 | return this._buffer_type; 111 | } 112 | ,isEqualBufferType : function(i_type_value) 113 | { 114 | return this._buffer_type==i_type_value; 115 | } 116 | ,getBuffer : function() 117 | { 118 | throw new NyARException(); 119 | } 120 | ,hasBuffer : function() 121 | { 122 | throw new NyARException(); 123 | } 124 | ,wrapBuffer : function(i_ref_buf) 125 | { 126 | throw new NyARException(); 127 | } 128 | }) 129 | 130 | NyARBinRaster = ASKlass('NyARBinRaster', NyARRaster_BasicClass, 131 | { 132 | _buf : null, 133 | /** 134 | * バッファオブジェクトがアタッチされていればtrue 135 | */ 136 | _is_attached_buffer : null, 137 | /** 138 | * 139 | */ 140 | NyARBinRaster : function() 141 | { 142 | NyARRaster_BasicClass.initialize.call(this, NyAS3Const_Inherited); 143 | switch(arguments.length) { 144 | case 1: 145 | if (arguments[0] == NyAS3Const_Inherited) { 146 | //blank 147 | } 148 | break; 149 | case 2: 150 | //(int,int) 151 | this.override_NyARBinRaster2(toInt(arguments[0]), toInt(arguments[1])); 152 | break; 153 | case 3: 154 | //(int,int,bool) 155 | this.override_NyARBinRaster3(toInt(arguments[0]), toInt(arguments[1]),Boolean(arguments[2])); 156 | break; 157 | case 4: 158 | //(int,int,int,bool) 159 | this.override_NyARBinRaster4(toInt(arguments[0]), toInt(arguments[1]),toInt(arguments[2]),Boolean(arguments[3])); 160 | break; 161 | default: 162 | throw new NyARException(); 163 | } 164 | } 165 | /** 166 | * 167 | * @param i_width 168 | * @param i_height 169 | * @param i_raster_type 170 | * NyARBufferTypeに定義された定数値を指定してください。 171 | * @param i_is_alloc 172 | * @throws NyARException 173 | */ 174 | ,override_NyARBinRaster4 : function(i_width, i_height, i_raster_type, i_is_alloc) 175 | { 176 | NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,i_width,i_height,i_raster_type); 177 | if(!this.initInstance(this._size,i_raster_type,i_is_alloc)){ 178 | throw new NyARException(); 179 | } 180 | } 181 | ,override_NyARBinRaster3 : function(i_width, i_height, i_is_alloc) 182 | { 183 | NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,i_width,i_height,NyARBufferType.INT1D_BIN_8); 184 | if(!this.initInstance(this._size,NyARBufferType.INT1D_BIN_8,i_is_alloc)){ 185 | throw new NyARException(); 186 | } 187 | } 188 | ,override_NyARBinRaster2 : function(i_width, i_height) 189 | { 190 | NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,i_width,i_height,NyARBufferType.INT1D_BIN_8); 191 | if(!this.initInstance(this._size,NyARBufferType.INT1D_BIN_8,true)){ 192 | throw new NyARException(); 193 | } 194 | } 195 | ,initInstance : function(i_size,i_buf_type,i_is_alloc) 196 | { 197 | switch(i_buf_type) 198 | { 199 | case NyARBufferType.INT1D_BIN_8: 200 | this._buf = i_is_alloc?new IntVector(i_size.w*i_size.h):null; 201 | break; 202 | default: 203 | return false; 204 | } 205 | this._is_attached_buffer=i_is_alloc; 206 | return true; 207 | } 208 | ,getBuffer : function() 209 | { 210 | return this._buf; 211 | } 212 | /** 213 | * インスタンスがバッファを所有するかを返します。 214 | * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、 215 | * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。 216 | * @return 217 | */ 218 | ,hasBuffer : function() 219 | { 220 | return this._buf!=null; 221 | } 222 | ,wrapBuffer : function(i_ref_buf) 223 | { 224 | NyAS3Utils.assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。 225 | this._buf=i_ref_buf; 226 | } 227 | }) 228 | 229 | 230 | 231 | 232 | 233 | NyARGrayscaleRaster = ASKlass('NyARGrayscaleRaster', NyARRaster_BasicClass, 234 | { 235 | _buf : null, 236 | /** 237 | * バッファオブジェクトがアタッチされていればtrue 238 | */ 239 | _is_attached_buffer : null, 240 | NyARGrayscaleRaster : function() 241 | { 242 | NyARRaster_BasicClass.initialize.call(this, NyAS3Const_Inherited); 243 | switch(arguments.length) { 244 | case 1: 245 | if (arguments[0] == NyAS3Const_Inherited) { 246 | //blank 247 | } 248 | break; 249 | case 2: 250 | //(int,int) 251 | this.overload_NyARGrayscaleRaster2(toInt(arguments[0]), toInt(arguments[1])); 252 | break; 253 | case 3: 254 | //(int,int,boolean) 255 | this.overload_NyARGrayscaleRaster3(toInt(arguments[0]), toInt(arguments[1]),Boolean(arguments[2])); 256 | break; 257 | case 4: 258 | //(int,int,int,boolean) 259 | this.overload_NyARGrayscaleRaster4(toInt(arguments[0]), toInt(arguments[1]),toInt(arguments[2]),Boolean(arguments[3])); 260 | break; 261 | default: 262 | throw new NyARException(); 263 | } 264 | } 265 | ,overload_NyARGrayscaleRaster2 : function(i_width,i_height) 266 | { 267 | NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,i_width,i_height,NyARBufferType.INT1D_GRAY_8); 268 | if(!this.initInstance(this._size,NyARBufferType.INT1D_GRAY_8,true)){ 269 | throw new NyARException(); 270 | } 271 | } 272 | ,overload_NyARGrayscaleRaster3 : function(i_width,i_height,i_is_alloc) 273 | { 274 | NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,i_width,i_height,NyARBufferType.INT1D_GRAY_8); 275 | if(!this.initInstance(this._size,NyARBufferType.INT1D_GRAY_8,i_is_alloc)){ 276 | throw new NyARException(); 277 | } 278 | } 279 | /** 280 | * @param i_width 281 | * @param i_height 282 | * @param i_raster_type 283 | * NyARBufferTypeに定義された定数値を指定してください。 284 | * @param i_is_alloc 285 | * @throws NyARException 286 | */ 287 | ,overload_NyARGrayscaleRaster4 : function(i_width, i_height, i_raster_type, i_is_alloc) 288 | { 289 | NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,i_width,i_height,i_raster_type); 290 | if(!this.initInstance(this._size,i_raster_type,i_is_alloc)){ 291 | throw new NyARException(); 292 | } 293 | } 294 | ,initInstance : function(i_size,i_buf_type,i_is_alloc) 295 | { 296 | switch(i_buf_type) 297 | { 298 | case NyARBufferType.INT1D_GRAY_8: 299 | this._buf =i_is_alloc?new IntVector(i_size.w*i_size.h):null; 300 | break; 301 | default: 302 | return false; 303 | } 304 | this._is_attached_buffer=i_is_alloc; 305 | return true; 306 | } 307 | ,getBuffer : function() 308 | { 309 | return this._buf; 310 | } 311 | /** 312 | * インスタンスがバッファを所有するかを返します。 313 | * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、 314 | * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。 315 | * @return 316 | */ 317 | ,hasBuffer : function() 318 | { 319 | return this._buf!=null; 320 | } 321 | ,wrapBuffer : function(i_ref_buf) 322 | { 323 | NyAS3Utils.assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。 324 | this._buf=i_ref_buf; 325 | } 326 | }) 327 | 328 | 329 | 330 | 331 | /**このクラスは、単機能のNyARRasterです。 332 | * 333 | */ 334 | NyARRaster = ASKlass('NyARRaster', NyARRaster_BasicClass, 335 | { 336 | _buf : null, 337 | _buf_type : 0, 338 | /** 339 | * バッファオブジェクトがアタッチされていればtrue 340 | */ 341 | _is_attached_buffer : null, 342 | NyARRaster : function() 343 | { 344 | NyARRaster_BasicClass.initialize.call(this, NyAS3Const_Inherited); 345 | switch(arguments.length) { 346 | case 1: 347 | if (arguments[0] == NyAS3Const_Inherited) { 348 | //blank 349 | } 350 | break; 351 | case 3: 352 | this.overload_NyARRaster3(toInt(arguments[0]), toInt(arguments[1]),toInt(arguments[2])); 353 | break; 354 | case 4: 355 | this.overload_NyARRaster4(toInt(arguments[0]), toInt(arguments[1]),toInt(arguments[2]),Boolean(arguments[3])); 356 | break; 357 | default: 358 | throw new NyARException(); 359 | } 360 | } 361 | /** 362 | * 指定したバッファタイプのラスタを作成します。 363 | * @param i_width 364 | * @param i_height 365 | * @param i_buffer_type 366 | * NyARBufferTypeに定義された定数値を指定してください。 367 | * @param i_is_alloc 368 | * @throws NyARException 369 | */ 370 | ,overload_NyARRaster4 : function(i_width, i_height, i_buffer_type, i_is_alloc) 371 | { 372 | NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,i_width,i_height,i_buffer_type); 373 | if(!this.initInstance(this._size,i_buffer_type,i_is_alloc)){ 374 | throw new NyARException(); 375 | } 376 | return; 377 | } 378 | ,overload_NyARRaster3 : function(i_width, i_height, i_buffer_type) 379 | { 380 | NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,i_width,i_height,i_buffer_type); 381 | if(!this.initInstance(this._size,i_buffer_type,true)){ 382 | throw new NyARException(); 383 | } 384 | return; 385 | } 386 | ,initInstance : function(i_size,i_buf_type,i_is_alloc) 387 | { 388 | switch(i_buf_type) 389 | { 390 | case NyARBufferType.INT1D_X8R8G8B8_32: 391 | this._buf=i_is_alloc?new IntVector(i_size.w*i_size.h):null; 392 | break; 393 | default: 394 | return false; 395 | } 396 | this._is_attached_buffer=i_is_alloc; 397 | return true; 398 | } 399 | ,getBuffer : function() 400 | { 401 | return this._buf; 402 | } 403 | /** 404 | * インスタンスがバッファを所有するかを返します。 405 | * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、 406 | * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。 407 | * @return 408 | */ 409 | ,hasBuffer : function() 410 | { 411 | return this._buf!=null; 412 | } 413 | ,wrapBuffer : function(i_ref_buf) 414 | { 415 | NyAS3Utils.assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。 416 | this._buf=i_ref_buf; 417 | } 418 | }) 419 | 420 | 421 | /** 422 | * 8bitRGBを表現できるラスタ 423 | * 424 | */ 425 | INyARRgbRaster = ASKlass('INyARRgbRaster', INyARRaster, { 426 | getRgbPixelReader : function(){} 427 | }) 428 | /** 429 | * NyARRasterインタフェイスの基本関数/メンバを実装したクラス 430 | * 431 | * 432 | */ 433 | NyARRgbRaster_BasicClass = ASKlass('NyARRgbRaster_BasicClass', INyARRgbRaster, 434 | { 435 | _size : null, 436 | _buffer_type : 0, 437 | NyARRgbRaster_BasicClass : function() 438 | { 439 | switch(arguments.length) { 440 | case 1: 441 | if (arguments[0] == NyAS3Const_Inherited) { 442 | //blank 443 | } 444 | break; 445 | case 3: 446 | //(int,int,int) 447 | this.overload_NyARRgbRaster_BasicClass(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2])); 448 | break; 449 | default: 450 | throw new NyARException(); 451 | } 452 | } 453 | ,overload_NyARRgbRaster_BasicClass : function(i_width,i_height,i_buffer_type) 454 | { 455 | this._size= new NyARIntSize(i_width,i_height); 456 | this._buffer_type=i_buffer_type; 457 | } 458 | ,getWidth : function() 459 | { 460 | return this._size.w; 461 | } 462 | ,getHeight : function() 463 | { 464 | return this._size.h; 465 | } 466 | ,getSize : function() 467 | { 468 | return this._size; 469 | } 470 | ,getBufferType : function() 471 | { 472 | return this._buffer_type; 473 | } 474 | ,isEqualBufferType : function(i_type_value) 475 | { 476 | return this._buffer_type==i_type_value; 477 | } 478 | ,getRgbPixelReader : function() 479 | { 480 | throw new NyARException(); 481 | } 482 | ,getBuffer : function() 483 | { 484 | throw new NyARException(); 485 | } 486 | ,hasBuffer : function() 487 | { 488 | throw new NyARException(); 489 | } 490 | ,wrapBuffer : function(i_ref_buf) 491 | { 492 | throw new NyARException(); 493 | } 494 | }) 495 | 496 | NyARRgbRaster = ASKlass('NyARRgbRaster', NyARRgbRaster_BasicClass, 497 | { 498 | _buf : null, 499 | _reader : null, 500 | /** 501 | * バッファオブジェクトがアタッチされていればtrue 502 | */ 503 | _is_attached_buffer : null, 504 | NyARRgbRaster : function() 505 | { 506 | NyARRgbRaster_BasicClass.initialize.call(this, NyAS3Const_Inherited); 507 | switch(arguments.length) { 508 | case 1: 509 | if (arguments[0] == NyAS3Const_Inherited) { 510 | //blank 511 | } 512 | break; 513 | case 3: 514 | this.overload_NyARRgbRaster3(toInt(arguments[0]), toInt(arguments[1]),toInt(arguments[2])); 515 | break; 516 | case 4: 517 | this.overload_NyARRgbRaster4(toInt(arguments[0]), toInt(arguments[1]),toInt(arguments[2]),Boolean(arguments[3])); 518 | break; 519 | default: 520 | throw new NyARException(); 521 | } 522 | } 523 | /** 524 | * 525 | * @param i_width 526 | * @param i_height 527 | * @param i_raster_type 528 | * NyARBufferTypeに定義された定数値を指定してください。 529 | * @param i_is_alloc 530 | * @throws NyARException 531 | */ 532 | ,overload_NyARRgbRaster4 : function(i_width,i_height,i_raster_type,i_is_alloc) 533 | { 534 | NyARRgbRaster_BasicClass.overload_NyARRgbRaster_BasicClass.call(this,i_width,i_height,i_raster_type); 535 | if(!this.initInstance(this._size,i_raster_type,i_is_alloc)){ 536 | throw new NyARException(); 537 | } 538 | } 539 | /** 540 | * 541 | * @param i_width 542 | * @param i_height 543 | * @param i_raster_type 544 | * NyARBufferTypeに定義された定数値を指定してください。 545 | * @throws NyARException 546 | */ 547 | ,overload_NyARRgbRaster3 : function(i_width, i_height, i_raster_type) 548 | { 549 | NyARRgbRaster_BasicClass.overload_NyARRgbRaster_BasicClass.call(this,i_width,i_height,i_raster_type); 550 | if(!this.initInstance(this._size,i_raster_type,true)){ 551 | throw new NyARException(); 552 | } 553 | } 554 | ,initInstance : function(i_size,i_raster_type,i_is_alloc) 555 | { 556 | switch(i_raster_type) 557 | { 558 | case NyARBufferType.INT1D_X8R8G8B8_32: 559 | this._buf=i_is_alloc?new IntVector(i_size.w*i_size.h):null; 560 | this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._buf||new IntVector(1),i_size); 561 | break; 562 | case NyARBufferType.BYTE1D_B8G8R8X8_32: 563 | case NyARBufferType.BYTE1D_R8G8B8_24: 564 | default: 565 | return false; 566 | } 567 | this._is_attached_buffer=i_is_alloc; 568 | return true; 569 | } 570 | ,getRgbPixelReader : function() 571 | { 572 | return this._reader; 573 | } 574 | ,getBuffer : function() 575 | { 576 | return this._buf; 577 | } 578 | ,hasBuffer : function() 579 | { 580 | return this._buf!=null; 581 | } 582 | ,wrapBuffer : function(i_ref_buf) 583 | { 584 | NyAS3Utils.assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。 585 | this._buf=i_ref_buf; 586 | //ピクセルリーダーの参照バッファを切り替える。 587 | this._reader.switchBuffer(i_ref_buf); 588 | } 589 | }) 590 | 591 | 592 | 593 | NyARRgbRaster_Canvas2D = ASKlass("NyARRgbRaster_Canvas2D", NyARRgbRaster_BasicClass, 594 | { 595 | _canvas : null, 596 | _rgb_reader: null, 597 | 598 | NyARRgbRaster_Canvas2D : function(canvas) { 599 | NyARRgbRaster_BasicClass.initialize.call(this, canvas.width, canvas.height, NyARBufferType.OBJECT_JS_Canvas); 600 | this._canvas = canvas; 601 | this._rgb_reader = new NyARRgbPixelReader_Canvas2D(this._canvas); 602 | }, 603 | getRgbPixelReader : function() 604 | { 605 | return this._rgb_reader; 606 | }, 607 | getBuffer:function() 608 | { 609 | return this._canvas; 610 | }, 611 | hasBuffer:function() 612 | { 613 | return this._bitmapData != null; 614 | } 615 | }) 616 | 617 | -------------------------------------------------------------------------------- /src/NyARRasterAnalyzer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | NyARRasterAnalyzer_Histogram = ASKlass('NyARRasterAnalyzer_Histogram', 34 | { 35 | _histImpl : null, 36 | /** 37 | * ヒストグラム解析の縦方向スキップ数。継承クラスはこのライン数づつ 38 | * スキップしながらヒストグラム計算を行うこと。 39 | */ 40 | _vertical_skip : 0, 41 | NyARRasterAnalyzer_Histogram : function(i_raster_format, i_vertical_interval) 42 | { 43 | if(!this.initInstance(i_raster_format,i_vertical_interval)){ 44 | throw new NyARException(); 45 | } 46 | } 47 | ,initInstance : function(i_raster_format,i_vertical_interval) 48 | { 49 | switch (i_raster_format) { 50 | case NyARBufferType.INT1D_GRAY_8: 51 | this._histImpl = new NyARRasterThresholdAnalyzer_Histogram_INT1D_GRAY_8(); 52 | break; 53 | case NyARBufferType.INT1D_X8R8G8B8_32: 54 | this._histImpl = new NyARRasterThresholdAnalyzer_Histogram_INT1D_X8R8G8B8_32(); 55 | break; 56 | default: 57 | return false; 58 | } 59 | //初期化 60 | this._vertical_skip=i_vertical_interval; 61 | return true; 62 | } 63 | ,setVerticalInterval : function(i_step) 64 | { 65 | this._vertical_skip=i_step; 66 | return; 67 | } 68 | /** 69 | * o_histgramにヒストグラムを出力します。 70 | * @param i_input 71 | * @param o_histgram 72 | * @return 73 | * @throws NyARException 74 | */ 75 | ,analyzeRaster : function(i_input,o_histgram) 76 | { 77 | var size=i_input.getSize(); 78 | //最大画像サイズの制限 79 | NyAS3Utils.assert(size.w*size.h<0x40000000); 80 | NyAS3Utils.assert(o_histgram.length == 256);//現在は固定 81 | var h=o_histgram.data; 82 | //ヒストグラム初期化 83 | for (var i = o_histgram.length-1; i >=0; i--){ 84 | h[i] = 0; 85 | } 86 | o_histgram.total_of_data=size.w*size.h/this._vertical_skip; 87 | return this._histImpl.createHistogram(i_input, size,h,this._vertical_skip); 88 | } 89 | }) 90 | ICreateHistogramImpl = ASKlass('ICreateHistogramImpl', 91 | { 92 | createHistogram : function(i_reader,i_size,o_histgram,i_skip){} 93 | }) 94 | 95 | NyARRasterThresholdAnalyzer_Histogram_INT1D_GRAY_8 = ASKlass('NyARRasterThresholdAnalyzer_Histogram_INT1D_GRAY_8', ICreateHistogramImpl, 96 | { 97 | createHistogram : function(i_reader,i_size,o_histgram,i_skip) 98 | { 99 | NyAS3Utils.assert (i_reader.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); 100 | var input=(IntVector)(i_reader.getBuffer()); 101 | for (var y = i_size.h-1; y >=0 ; y-=i_skip){ 102 | var pt=y*i_size.w; 103 | for (var x = i_size.w-1; x >=0; x--) { 104 | o_histgram[input[pt]]++; 105 | pt++; 106 | } 107 | } 108 | return i_size.w*i_size.h; 109 | } 110 | }) 111 | NyARRasterThresholdAnalyzer_Histogram_INT1D_X8R8G8B8_32 = ASKlass('NyARRasterThresholdAnalyzer_Histogram_INT1D_X8R8G8B8_32', ICreateHistogramImpl, 112 | { 113 | createHistogram : function(i_reader,i_size,o_histgram,i_skip) 114 | { 115 | NyAS3Utils.assert (i_reader.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32)); 116 | var input =(i_reader.getBuffer()); 117 | for (var y = i_size.h-1; y >=0 ; y-=i_skip){ 118 | var pt=y*i_size.w; 119 | for (var x = i_size.w-1; x >=0; x--) { 120 | var p=input[pt]; 121 | o_histgram[((p& 0xff)+(p& 0xff)+(p& 0xff))/3]++; 122 | pt++; 123 | } 124 | } 125 | return i_size.w*i_size.h; 126 | } 127 | }) 128 | INyARRasterThresholdAnalyzer = ASKlass('INyARRasterThresholdAnalyzer', 129 | { 130 | analyzeRaster : function(i_input){} 131 | }) 132 | NyARRasterThresholdAnalyzer_SlidePTile = ASKlass('NyARRasterThresholdAnalyzer_SlidePTile', INyARRasterThresholdAnalyzer, 133 | { 134 | _raster_analyzer : null, 135 | _sptile : null, 136 | _histgram : null, 137 | NyARRasterThresholdAnalyzer_SlidePTile : function(i_persentage, i_raster_format, i_vertical_interval) 138 | { 139 | NyAS3Utils.assert (0 <= i_persentage && i_persentage <= 50); 140 | //初期化 141 | if(!this.initInstance(i_raster_format,i_vertical_interval)){ 142 | throw new NyARException(); 143 | } 144 | this._sptile=new NyARHistogramAnalyzer_SlidePTile(i_persentage); 145 | this._histgram=new NyARHistogram(256); 146 | } 147 | ,initInstance : function(i_raster_format,i_vertical_interval) 148 | { 149 | this._raster_analyzer=new NyARRasterAnalyzer_Histogram(i_raster_format,i_vertical_interval); 150 | return true; 151 | } 152 | ,setVerticalInterval : function(i_step) 153 | { 154 | this._raster_analyzer.setVerticalInterval(i_step); 155 | return; 156 | } 157 | ,analyzeRaster : function(i_input) 158 | { 159 | this._raster_analyzer.analyzeRaster(i_input, this._histgram); 160 | return this._sptile.getThreshold(this._histgram); 161 | } 162 | }) 163 | -------------------------------------------------------------------------------- /src/NyARRasterFilter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | INyARRasterFilter = ASKlass('INyARRasterFilter', 34 | { 35 | doFilter : function(i_input,i_output){} 36 | }) 37 | INyARRasterFilter_Gs2Bin = ASKlass('INyARRasterFilter_Gs2Bin', 38 | { 39 | doFilter : function(i_input, i_output){} 40 | }) 41 | INyARRasterFilter_Rgb2Gs = ASKlass('INyARRasterFilter_Rgb2Gs', 42 | { 43 | doFilter : function(i_input,i_output){} 44 | }) 45 | INyARRasterFilter_Rgb2Bin = ASKlass('INyARRasterFilter_Rgb2Bin', 46 | { 47 | doFilter : function(i_input, i_output){} 48 | }) 49 | 50 | 51 | 52 | 53 | 54 | 55 | /** 56 | * 定数閾値による2値化をする。 57 | * 58 | */ 59 | NyARRasterFilter_ARToolkitThreshold = ASKlass('NyARRasterFilter_ARToolkitThreshold', INyARRasterFilter_Rgb2Bin, 60 | { 61 | _threshold : 0, 62 | _do_threshold_impl : null, 63 | NyARRasterFilter_ARToolkitThreshold : function(i_threshold, i_input_raster_type) 64 | { 65 | this._threshold = i_threshold; 66 | switch (i_input_raster_type) { 67 | case NyARBufferType.INT1D_X8R8G8B8_32: 68 | this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32(); 69 | break; 70 | default: 71 | throw new NyARException(); 72 | } 73 | } 74 | /** 75 | * 画像を2値化するための閾値。暗点<=th<明点となります。 76 | * @param i_threshold 77 | */ 78 | ,setThreshold : function(i_threshold ) 79 | { 80 | this._threshold = i_threshold; 81 | } 82 | ,doFilter : function(i_input,i_output) 83 | { 84 | NyAS3Utils.assert (i_output.isEqualBufferType(NyARBufferType.INT1D_BIN_8)); 85 | NyAS3Utils.assert (i_input.getSize().isEqualSize_NyARIntSize(i_output.getSize()) == true); 86 | this._do_threshold_impl.doThFilter(i_input,i_output,i_output.getSize(), this._threshold); 87 | return; 88 | } 89 | }) 90 | 91 | 92 | 93 | 94 | 95 | /* 96 | * ここから各ラスタ用のフィルタ実装 97 | */ 98 | IdoThFilterImpl = ASKlass('IdoThFilterImpl', 99 | { 100 | doThFilter : function(i_input,i_output,i_size,i_threshold){}, 101 | }) 102 | 103 | doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32 = ASKlass('doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32', IdoThFilterImpl, 104 | { 105 | doThFilter : function(i_input,i_output,i_size,i_threshold) 106 | { 107 | NyAS3Utils.assert (i_output.isEqualBufferType(NyARBufferType.INT1D_BIN_8)); 108 | var out_buf = (IntVector)(i_output.getBuffer()); 109 | var in_buf = (IntVector)(i_input.getBuffer()); 110 | var th=i_threshold*3; 111 | var w; 112 | var xy; 113 | var pix_count=i_size.h*i_size.w; 114 | var pix_mod_part=pix_count-(pix_count%8); 115 | for(xy=pix_count-1;xy>=pix_mod_part;xy--){ 116 | w=in_buf[xy]; 117 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 118 | } 119 | //タイリング 120 | for (;xy>=0;) { 121 | w=in_buf[xy]; 122 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 123 | xy--; 124 | w=in_buf[xy]; 125 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 126 | xy--; 127 | w=in_buf[xy]; 128 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 129 | xy--; 130 | w=in_buf[xy]; 131 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 132 | xy--; 133 | w=in_buf[xy]; 134 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 135 | xy--; 136 | w=in_buf[xy]; 137 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 138 | xy--; 139 | w=in_buf[xy]; 140 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 141 | xy--; 142 | w=in_buf[xy]; 143 | out_buf[xy]=(((w>>16)&0xff)+((w>>8)&0xff)+(w&0xff))<=th?0:1; 144 | xy--; 145 | } 146 | } 147 | }) 148 | -------------------------------------------------------------------------------- /src/NyARRasterReader.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | 34 | /** 35 | * R8G8B8でピクセルを読み出すインタフェイス 36 | * 37 | */ 38 | INyARRgbPixelReader = ASKlass('INyARRgbPixelReader', { 39 | /** 40 | * 1ピクセルをint配列にして返します。 41 | * 42 | * @param i_x 43 | * @param i_y 44 | * @param o_rgb 45 | */ 46 | getPixel : function(i_x, i_y, o_rgb){}, 47 | /** 48 | * 複数のピクセル値をi_rgbへ返します。 49 | * 50 | * @param i_x 51 | * xのインデックス配列 52 | * @param i_y 53 | * yのインデックス配列 54 | * @param i_num 55 | * 返すピクセル値の数 56 | * @param i_rgb 57 | * ピクセル値を返すバッファ 58 | */ 59 | getPixelSet : function(i_x, i_y, i_num, o_rgb){}, 60 | /** 61 | * 1ピクセルを設定します。 62 | * @param i_x 63 | * @param i_y 64 | * @param i_rgb 65 | * @throws NyARException 66 | */ 67 | setPixel : function(i_x, i_y, i_rgb){}, 68 | /** 69 | * 複数のピクセル値をint配列から設定します。 70 | * @param i_x 71 | * @param i_y 72 | * @param i_num 73 | * @param i_intrgb 74 | * @throws NyARException 75 | */ 76 | setPixels : function(i_x, i_y, i_num, i_intrgb){}, 77 | switchBuffer : function(i_ref_buffer){} 78 | }) 79 | NyARRgbPixelReader_INT1D_X8R8G8B8_32 = ASKlass('NyARRgbPixelReader_INT1D_X8R8G8B8_32', INyARRgbPixelReader, 80 | { 81 | _ref_buf : null, 82 | _size : null, 83 | NyARRgbPixelReader_INT1D_X8R8G8B8_32 : function(i_buf, i_size) 84 | { 85 | this._ref_buf = i_buf; 86 | this._size = i_size; 87 | } 88 | ,getPixel : function(i_x,i_y,o_rgb) 89 | { 90 | var rgb= this._ref_buf[i_x + i_y * this._size.w]; 91 | o_rgb[0] = (rgb>>16)&0xff;// R 92 | o_rgb[1] = (rgb>>8)&0xff;// G 93 | o_rgb[2] = rgb&0xff;// B 94 | return; 95 | } 96 | ,getPixelSet : function(i_x,i_y,i_num, o_rgb) 97 | { 98 | var width = this._size.w; 99 | var ref_buf = this._ref_buf; 100 | for (var i = i_num - 1; i >= 0; i--) { 101 | var rgb=ref_buf[i_x[i] + i_y[i] * width]; 102 | o_rgb[i * 3 + 0] = (rgb>>16)&0xff;// R 103 | o_rgb[i * 3 + 1] = (rgb>>8)&0xff;// G 104 | o_rgb[i * 3 + 2] = rgb&0xff;// B 105 | } 106 | return; 107 | } 108 | ,setPixel : function(i_x,i_y,i_rgb) 109 | { 110 | this._ref_buf[i_x + i_y * this._size.w]=((i_rgb[0]<<16)&0xff)|((i_rgb[1]<<8)&0xff)|((i_rgb[2])&0xff); 111 | } 112 | ,setPixels : function(i_x,i_y, i_num,i_intrgb) 113 | { 114 | throw new NyARException(); 115 | } 116 | /** 117 | * 参照しているバッファをi_ref_bufferへ切り替えます。 118 | * 内部パラメータのチェックは、実装依存です。 119 | * @param i_ref_buffer 120 | * @throws NyARException 121 | */ 122 | ,switchBuffer : function(i_ref_buffer) 123 | { 124 | NyAS3Utils.assert(i_ref_buffer.length>=this._size.w*this._size.h); 125 | this._ref_buf = (i_ref_buffer); 126 | } 127 | }) 128 | 129 | 130 | NyARRgbPixelReader_Canvas2D = ASKlass("NyARRgbPixelReader_Canvas2D", INyARRgbPixelReader, 131 | { 132 | _ref_canvas: null, 133 | _data : null, 134 | 135 | NyARRgbPixelReader_Canvas2D : function(i_canvas) 136 | { 137 | this._ref_canvas = i_canvas; 138 | }, 139 | 140 | getData : function() { 141 | if (this._ref_canvas.changed || !this._data) { 142 | var canvas = this._ref_canvas; 143 | var ctx = canvas.getContext('2d'); 144 | this._data = ctx.getImageData(0,0,canvas.width,canvas.height); 145 | this._ref_canvas.changed = false; 146 | } 147 | return this._data; 148 | }, 149 | 150 | getPixel: function(i_x, i_y, o_rgb) 151 | { 152 | var idata = this.getData(); 153 | var w = idata.width; 154 | var h = idata.height; 155 | var d = idata.data; 156 | o_rgb[0] = d[i_y*w+i_x];// R 157 | o_rgb[1] = d[i_y*w+i_x+1];// G 158 | o_rgb[2] = d[i_y*w+i_x+2];// B 159 | return; 160 | }, 161 | 162 | getPixelSet: function(i_x, i_y, i_num, o_rgb) 163 | { 164 | var idata = this.getData(); 165 | var w = idata.width; 166 | var h = idata.height; 167 | var d = idata.data; 168 | for (var i = 0; i < i_num; i++) { 169 | var idx = i_y[i]*w*4 + i_x[i]*4; 170 | o_rgb[i*3+0] = d[idx+0]; 171 | o_rgb[i*3+1] = d[idx+1]; 172 | o_rgb[i*3+2] = d[idx+2]; 173 | } 174 | }, 175 | 176 | setPixel: function(i_x, i_y, i_rgb) 177 | { 178 | NyARException.notImplement(); 179 | }, 180 | setPixels: function(i_x, i_y, i_num, i_intrgb) 181 | { 182 | NyARException.notImplement(); 183 | }, 184 | switchBuffer:function(i_canvas) 185 | { 186 | NyARException.notImplement(); 187 | } 188 | 189 | }) 190 | 191 | -------------------------------------------------------------------------------- /src/NyARUtils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | 34 | 35 | NyARMath = Klass( 36 | { 37 | /** 38 | * p2-p1ベクトルのsquare normを計算する。 39 | * @param i_p1 40 | * @param i_p2 41 | * @return 42 | */ 43 | sqNorm_NyARDoublePoint2d : function(i_p1,i_p2 ) 44 | { 45 | var x,y; 46 | x=i_p2.x-i_p1.x; 47 | y=i_p2.y-i_p1.y; 48 | return x*x+y*y; 49 | }, 50 | sqNorm_Number : function(i_p1x,i_p1y,i_p2x,i_p2y) 51 | { 52 | var x,y; 53 | x=i_p2x-i_p1x; 54 | y=i_p2y-i_p1y; 55 | return x*x+y*y; 56 | }, 57 | /** 58 | * p2-p1ベクトルのsquare normを計算する。 59 | * @param i_p1 60 | * @param i_p2 61 | * @return 62 | */ 63 | sqNorm_NyARDoublePoint3d : function(i_p1,i_p2) 64 | { 65 | var x, y, z; 66 | x=i_p2.x-i_p1.x; 67 | y=i_p2.y-i_p1.y; 68 | z=i_p2.z-i_p1.z; 69 | return x*x+y*y+z*z; 70 | }, 71 | /** 72 | * 3乗根を求められないシステムで、3乗根を求めます。 73 | * http://aoki2.si.gunma-u.ac.jp/JavaScript/src/3jisiki.html 74 | * @param i_in 75 | * @return 76 | */ 77 | cubeRoot : function(i_in) 78 | { 79 | var res = Math.pow(Math.abs(i_in), 1.0 / 3.0); 80 | return (i_in >= 0) ? res : -res; 81 | } 82 | }) 83 | 84 | 85 | NyAREquationSolver = Klass( 86 | { 87 | solve2Equation_3 : function(i_a, i_b,i_c,o_result) 88 | { 89 | NyAS3Utils.assert(i_a!=0); 90 | return this.solve2Equation_2b(i_b/i_a,i_c/i_a,o_result,0); 91 | }, 92 | solve2Equation_2a : function(i_b, i_c,o_result) 93 | { 94 | return this.solve2Equation_2b(i_b,i_c,o_result,0); 95 | }, 96 | solve2Equation_2b : function(i_b, i_c,o_result,i_result_st) 97 | { 98 | var t=i_b*i_b-4*i_c; 99 | if(t<0){ 100 | //虚数根 101 | return 0; 102 | } 103 | if(t==0){ 104 | //重根 105 | o_result[i_result_st+0]=-i_b/(2); 106 | return 1; 107 | } 108 | //実根2個 109 | t=Math.sqrt(t); 110 | o_result[i_result_st+0]=(-i_b+t)/(2); 111 | o_result[i_result_st+1]=(-i_b-t)/(2); 112 | return 2; 113 | }, 114 | /** 115 | * 3次方程式 a*x^3+b*x^2+c*x+d=0の実根を求める。 116 | * http://aoki2.si.gunma-u.ac.jp/JavaScript/src/3jisiki.html 117 | * のコードを基にしてます。 118 | * @param i_a 119 | * X^3の係数 120 | * @param i_b 121 | * X^2の係数 122 | * @param i_c 123 | * X^1の係数 124 | * @param i_d 125 | * X^0の係数 126 | * @param o_result 127 | * 実根。double[3]を指定すること。 128 | * @return 129 | */ 130 | solve3Equation_4 : function(i_a, i_b, i_c, i_d,o_result) 131 | { 132 | NyAS3Utils.assert (i_a != 0); 133 | return this.solve3Equation_3(i_b/i_a,i_c/i_a,i_d/i_a,o_result); 134 | }, 135 | /** 136 | * 3次方程式 x^3+b*x^2+c*x+d=0の実根を求める。 137 | * だけを求める。 138 | * http://aoki2.si.gunma-u.ac.jp/JavaScript/src/3jisiki.html 139 | * のコードを基にしてます。 140 | * @param i_b 141 | * X^2の係数 142 | * @param i_c 143 | * X^1の係数 144 | * @param i_d 145 | * X^0の係数 146 | * @param o_result 147 | * 実根。double[1]以上を指定すること。 148 | * @return 149 | */ 150 | solve3Equation_3 : function(i_b,i_c,i_d,o_result) 151 | { 152 | var tmp,b, p, q; 153 | b = i_b/(3); 154 | p = b * b - i_c / 3; 155 | q = (b * (i_c - 2 * b * b) - i_d) / 2; 156 | if ((tmp = q * q - p * p * p) == 0) { 157 | // 重根 158 | q = NyARMath.cubeRoot(q); 159 | o_result[0] = 2 * q - b; 160 | o_result[1] = -q - b; 161 | return 2; 162 | } else if (tmp > 0) { 163 | // 実根1,虚根2 164 | var a3 = NyARMath.cubeRoot(q + ((q > 0) ? 1 : -1) * Math.sqrt(tmp)); 165 | var b3 = p / a3; 166 | o_result[0] = a3 + b3 - b; 167 | // 虚根:-0.5*(a3+b3)-b,Math.abs(a3-b3)*Math.sqrt(3.0)/2 168 | return 1; 169 | } else { 170 | // 実根3 171 | tmp = 2 * Math.sqrt(p); 172 | var t = Math.acos(q / (p * tmp / 2)); 173 | o_result[0] = tmp * Math.cos(t / 3) - b; 174 | o_result[1] = tmp * Math.cos((t + 2 * Math.PI) / 3) - b; 175 | o_result[2] = tmp * Math.cos((t + 4 * Math.PI) / 3) - b; 176 | return 3; 177 | } 178 | }, 179 | /** 180 | * 4次方程式の実根だけを求める。 181 | * @param i_a 182 | * X^3の係数 183 | * @param i_b 184 | * X^2の係数 185 | * @param i_c 186 | * X^1の係数 187 | * @param i_d 188 | * X^0の係数 189 | * @param o_result 190 | * 実根。double[3]を指定すること。 191 | * @return 192 | */ 193 | solve4Equation : function(i_a, i_b, i_c, i_d,i_e,o_result) 194 | { 195 | NyAS3Utils.assert (i_a != 0); 196 | var A3,A2,A1,A0,B3; 197 | A3=i_b/i_a; 198 | A2=i_c/i_a; 199 | A1=i_d/i_a; 200 | A0=i_e/i_a; 201 | B3=A3/4; 202 | var p,q,r; 203 | var B3_2=B3*B3; 204 | p=A2-6*B3_2;//A2-6*B3*B3; 205 | q=A1+B3*(-2*A2+8*B3_2);//A1-2*A2*B3+8*B3*B3*B3; 206 | r=A0+B3*(-A1+A2*B3)-3*B3_2*B3_2;//A0-A1*B3+A2*B3*B3-3*B3*B3*B3*B3; 207 | if(q==0){ 208 | var result_0,result_1; 209 | //複二次式 210 | var res=this.solve2Equation_2b(p,r,o_result,0); 211 | switch(res){ 212 | case 0: 213 | //全て虚数解 214 | return 0; 215 | case 1: 216 | //重根 217 | //解は0,1,2の何れか。 218 | result_0=o_result[0]; 219 | if(result_0<0){ 220 | //全て虚数解 221 | return 0; 222 | } 223 | //実根1個 224 | if(result_0==0){ 225 | //NC 226 | o_result[0]=0-B3; 227 | return 1; 228 | } 229 | //実根2個 230 | result_0=Math.sqrt(result_0); 231 | o_result[0]=result_0-B3; 232 | o_result[1]=-result_0-B3; 233 | return 2; 234 | case 2: 235 | //実根2個だからt==t2==0はありえない。(case1) 236 | //解は、0,2,4の何れか。 237 | result_0=o_result[0]; 238 | result_1=o_result[1]; 239 | var number_of_result=0; 240 | if(result_0>0){ 241 | //NC 242 | result_0=Math.sqrt(result_0); 243 | o_result[0]= result_0-B3; 244 | o_result[1]=-result_0-B3; 245 | number_of_result+=2; 246 | } 247 | if(result_1>0) 248 | { 249 | //NC 250 | result_1=Math.sqrt(result_1); 251 | o_result[number_of_result+0]= result_1-B3; 252 | o_result[number_of_result+1]=-result_1-B3; 253 | number_of_result+=2; 254 | } 255 | return number_of_result; 256 | default: 257 | throw new NyARException(); 258 | } 259 | }else{ 260 | //それ以外 261 | //最適化ポイント: 262 | //u^3 + (2*p)*u^2 +((- 4*r)+(p^2))*u -q^2= 0 263 | var u=this.solve3Equation_1((2*p),(- 4*r)+(p*p),-q*q); 264 | if(u<0){ 265 | //全て虚数解 266 | return 0; 267 | } 268 | var ru=Math.sqrt(u); 269 | //2次方程式を解いてyを計算(最適化ポイント) 270 | var result_1st,result_2nd; 271 | result_1st=this.solve2Equation_2b(-ru,(p+u)/2+ru*q/(2*u),o_result,0); 272 | //配列使い回しのために、変数に退避 273 | switch(result_1st){ 274 | case 0: 275 | break; 276 | case 1: 277 | o_result[0]=o_result[0]-B3; 278 | break; 279 | case 2: 280 | o_result[0]=o_result[0]-B3; 281 | o_result[1]=o_result[1]-B3; 282 | break; 283 | default: 284 | throw new NyARException(); 285 | } 286 | result_2nd=this.solve2Equation_2b(ru,(p+u)/2-ru*q/(2*u),o_result,result_1st); 287 | //0,1番目に格納 288 | switch(result_2nd){ 289 | case 0: 290 | break; 291 | case 1: 292 | o_result[result_1st+0]=o_result[result_1st+0]-B3; 293 | break; 294 | case 2: 295 | o_result[result_1st+0]=o_result[result_1st+0]-B3; 296 | o_result[result_1st+1]=o_result[result_1st+1]-B3; 297 | break; 298 | default: 299 | throw new NyARException(); 300 | } 301 | return result_1st+result_2nd; 302 | } 303 | }, 304 | /** 305 | * 3次方程式の実根を1個だけ求める。 306 | * 4字方程式で使う。 307 | * @param i_b 308 | * @param i_c 309 | * @param i_d 310 | * @param o_result 311 | * @return 312 | */ 313 | solve3Equation_1 : function(i_b,i_c, i_d) 314 | { 315 | var tmp,b, p, q; 316 | b = i_b/(3); 317 | p = b * b - i_c / 3; 318 | q = (b * (i_c - 2 * b * b) - i_d) / 2; 319 | if ((tmp = q * q - p * p * p) == 0) { 320 | // 重根 321 | q = NyARMath.cubeRoot(q); 322 | return 2 * q - b; 323 | } else if (tmp > 0) { 324 | // 実根1,虚根2 325 | var a3 = NyARMath.cubeRoot(q + ((q > 0) ? 1 : -1) * Math.sqrt(tmp)); 326 | var b3 = p / a3; 327 | return a3 + b3 - b; 328 | } else { 329 | // 実根3 330 | tmp = 2 * Math.sqrt(p); 331 | var t = Math.acos(q / (p * tmp / 2)); 332 | return tmp * Math.cos(t / 3) - b; 333 | } 334 | } 335 | }) 336 | 337 | NyARPerspectiveParamGenerator_O1 = Klass( 338 | { 339 | _local_x : 0, 340 | _local_y : 0, 341 | _width : 0, 342 | _height : 0, 343 | initialize : function(i_local_x,i_local_y,i_width,i_height) 344 | { 345 | this._height=i_height; 346 | this._width=i_width; 347 | this._local_x=i_local_x; 348 | this._local_y=i_local_y; 349 | return; 350 | }, 351 | getParam : function(i_vertex,o_param) 352 | { 353 | var ltx = this._local_x; 354 | var lty = this._local_y; 355 | var rbx = ltx + this._width; 356 | var rby = lty + this._height; 357 | var det_1; 358 | var a13, a14, a23, a24, a33, a34, a43, a44; 359 | var b11, b12, b13, b14, b21, b22, b23, b24, b31, b32, b33, b34, b41, b42, b43, b44; 360 | var t1, t2, t3, t4, t5, t6; 361 | var v1, v2, v3, v4; 362 | var kx0, kx1, kx2, kx3, kx4, kx5, kx6, kx7; 363 | var ky0, ky1, ky2, ky3, ky4, ky5, ky6, ky7; 364 | { 365 | v1 = i_vertex[0].x; 366 | v2 = i_vertex[1].x; 367 | v3 = i_vertex[2].x; 368 | v4 = i_vertex[3].x; 369 | a13 = -ltx * v1; 370 | a14 = -lty * v1; 371 | a23 = -rbx * v2; 372 | a24 = -lty * v2; 373 | a33 = -rbx * v3; 374 | a34 = -rby * v3; 375 | a43 = -ltx * v4; 376 | a44 = -rby * v4; 377 | t1 = a33 * a44 - a34 * a43; 378 | t4 = a34 * ltx - rbx * a44; 379 | t5 = rbx * a43 - a33 * ltx; 380 | t2 = rby * (a34 - a44); 381 | t3 = rby * (a43 - a33); 382 | t6 = rby * (rbx - ltx); 383 | b21 = -a23 * t4 - a24 * t5 - rbx * t1; 384 | b11 = (a23 * t2 + a24 * t3) + lty * t1; 385 | b31 = (a24 * t6 - rbx * t2) + lty * t4; 386 | b41 = (-rbx * t3 - a23 * t6) + lty * t5; 387 | t1 = a43 * a14 - a44 * a13; 388 | t2 = a44 * lty - rby * a14; 389 | t3 = rby * a13 - a43 * lty; 390 | t4 = ltx * (a44 - a14); 391 | t5 = ltx * (a13 - a43); 392 | t6 = ltx * (lty - rby); 393 | b12 = -rby * t1 - a33 * t2 - a34 * t3; 394 | b22 = (a33 * t4 + a34 * t5) + rbx * t1; 395 | b32 = (-a34 * t6 - rby * t4) + rbx * t2; 396 | b42 = (-rby * t5 + a33 * t6) + rbx * t3; 397 | t1 = a13 * a24 - a14 * a23; 398 | t4 = a14 * rbx - ltx * a24; 399 | t5 = ltx * a23 - a13 * rbx; 400 | t2 = lty * (a14 - a24); 401 | t3 = lty * (a23 - a13); 402 | t6 = lty * (ltx - rbx); 403 | b23 = -a43 * t4 - a44 * t5 - ltx * t1; 404 | b13 = (a43 * t2 + a44 * t3) + rby * t1; 405 | b33 = (a44 * t6 - ltx * t2) + rby * t4; 406 | b43 = (-ltx * t3 - a43 * t6) + rby * t5; 407 | t1 = a23 * a34 - a24 * a33; 408 | t2 = a24 * rby - lty * a34; 409 | t3 = lty * a33 - a23 * rby; 410 | t4 = rbx * (a24 - a34); 411 | t5 = rbx * (a33 - a23); 412 | t6 = rbx * (rby - lty); 413 | b14 = -lty * t1 - a13 * t2 - a14 * t3; 414 | b24 = a13 * t4 + a14 * t5 + ltx * t1; 415 | b34 = -a14 * t6 - lty * t4 + ltx * t2; 416 | b44 = -lty * t5 + a13 * t6 + ltx * t3; 417 | det_1 = (ltx * (b11 + b14) + rbx * (b12 + b13)); 418 | if (det_1 == 0) { 419 | det_1=0.0001; 420 | //System.out.println("Could not get inverse matrix(1)."); 421 | //return false; 422 | } 423 | det_1 = 1 / det_1; 424 | kx0 = (b11 * v1 + b12 * v2 + b13 * v3 + b14 * v4) * det_1; 425 | kx1 = (b11 + b12 + b13 + b14) * det_1; 426 | kx2 = (b21 * v1 + b22 * v2 + b23 * v3 + b24 * v4) * det_1; 427 | kx3 = (b21 + b22 + b23 + b24) * det_1; 428 | kx4 = (b31 * v1 + b32 * v2 + b33 * v3 + b34 * v4) * det_1; 429 | kx5 = (b31 + b32 + b33 + b34) * det_1; 430 | kx6 = (b41 * v1 + b42 * v2 + b43 * v3 + b44 * v4) * det_1; 431 | kx7 = (b41 + b42 + b43 + b44) * det_1; 432 | } 433 | { 434 | v1 = i_vertex[0].y; 435 | v2 = i_vertex[1].y; 436 | v3 = i_vertex[2].y; 437 | v4 = i_vertex[3].y; 438 | a13 = -ltx * v1; 439 | a14 = -lty * v1; 440 | a23 = -rbx * v2; 441 | a24 = -lty * v2; 442 | a33 = -rbx * v3; 443 | a34 = -rby * v3; 444 | a43 = -ltx * v4; 445 | a44 = -rby * v4; 446 | t1 = a33 * a44 - a34 * a43; 447 | t4 = a34 * ltx - rbx * a44; 448 | t5 = rbx * a43 - a33 * ltx; 449 | t2 = rby * (a34 - a44); 450 | t3 = rby * (a43 - a33); 451 | t6 = rby * (rbx - ltx); 452 | b21 = -a23 * t4 - a24 * t5 - rbx * t1; 453 | b11 = (a23 * t2 + a24 * t3) + lty * t1; 454 | b31 = (a24 * t6 - rbx * t2) + lty * t4; 455 | b41 = (-rbx * t3 - a23 * t6) + lty * t5; 456 | t1 = a43 * a14 - a44 * a13; 457 | t2 = a44 * lty - rby * a14; 458 | t3 = rby * a13 - a43 * lty; 459 | t4 = ltx * (a44 - a14); 460 | t5 = ltx * (a13 - a43); 461 | t6 = ltx * (lty - rby); 462 | b12 = -rby * t1 - a33 * t2 - a34 * t3; 463 | b22 = (a33 * t4 + a34 * t5) + rbx * t1; 464 | b32 = (-a34 * t6 - rby * t4) + rbx * t2; 465 | b42 = (-rby * t5 + a33 * t6) + rbx * t3; 466 | t1 = a13 * a24 - a14 * a23; 467 | t4 = a14 * rbx - ltx * a24; 468 | t5 = ltx * a23 - a13 * rbx; 469 | t2 = lty * (a14 - a24); 470 | t3 = lty * (a23 - a13); 471 | t6 = lty * (ltx - rbx); 472 | b23 = -a43 * t4 - a44 * t5 - ltx * t1; 473 | b13 = (a43 * t2 + a44 * t3) + rby * t1; 474 | b33 = (a44 * t6 - ltx * t2) + rby * t4; 475 | b43 = (-ltx * t3 - a43 * t6) + rby * t5; 476 | t1 = a23 * a34 - a24 * a33; 477 | t2 = a24 * rby - lty * a34; 478 | t3 = lty * a33 - a23 * rby; 479 | t4 = rbx * (a24 - a34); 480 | t5 = rbx * (a33 - a23); 481 | t6 = rbx * (rby - lty); 482 | b14 = -lty * t1 - a13 * t2 - a14 * t3; 483 | b24 = a13 * t4 + a14 * t5 + ltx * t1; 484 | b34 = -a14 * t6 - lty * t4 + ltx * t2; 485 | b44 = -lty * t5 + a13 * t6 + ltx * t3; 486 | det_1 = (ltx * (b11 + b14) + rbx * (b12 + b13)); 487 | if (det_1 == 0) { 488 | det_1=0.0001; 489 | //System.out.println("Could not get inverse matrix(2)."); 490 | //return false; 491 | } 492 | det_1 = 1 / det_1; 493 | ky0 = (b11 * v1 + b12 * v2 + b13 * v3 + b14 * v4) * det_1; 494 | ky1 = (b11 + b12 + b13 + b14) * det_1; 495 | ky2 = (b21 * v1 + b22 * v2 + b23 * v3 + b24 * v4) * det_1; 496 | ky3 = (b21 + b22 + b23 + b24) * det_1; 497 | ky4 = (b31 * v1 + b32 * v2 + b33 * v3 + b34 * v4) * det_1; 498 | ky5 = (b31 + b32 + b33 + b34) * det_1; 499 | ky6 = (b41 * v1 + b42 * v2 + b43 * v3 + b44 * v4) * det_1; 500 | ky7 = (b41 + b42 + b43 + b44) * det_1; 501 | } 502 | det_1 = kx5 * (-ky7) - (-ky5) * kx7; 503 | if (det_1 == 0) { 504 | det_1=0.0001; 505 | //System.out.println("Could not get inverse matrix(3)."); 506 | //return false; 507 | } 508 | det_1 = 1 / det_1; 509 | var C, F; 510 | o_param[2] = C = (-ky7 * det_1) * (kx4 - ky4) + (ky5 * det_1) * (kx6 - ky6); // C 511 | o_param[5] = F = (-kx7 * det_1) * (kx4 - ky4) + (kx5 * det_1) * (kx6 - ky6); // F 512 | o_param[6] = kx4 - C * kx5; 513 | o_param[7] = kx6 - C * kx7; 514 | o_param[0] = kx0 - C * kx1; 515 | o_param[1] = kx2 - C * kx3; 516 | o_param[3] = ky0 - F * ky1; 517 | o_param[4] = ky2 - F * ky3; 518 | return true; 519 | } 520 | }) 521 | -------------------------------------------------------------------------------- /src/NyUtils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JSARToolkit 3 | * -------------------------------------------------------------------------------- 4 | * This work is based on the original ARToolKit developed by 5 | * Hirokazu Kato 6 | * Mark Billinghurst 7 | * HITLab, University of Washington, Seattle 8 | * http://www.hitl.washington.edu/artoolkit/ 9 | * 10 | * And the NyARToolkitAS3 ARToolKit class library. 11 | * Copyright (C)2010 Ryo Iizuka 12 | * 13 | * JSARToolkit is a JavaScript port of NyARToolkitAS3. 14 | * Copyright (C)2010 Ilmari Heikkinen 15 | * 16 | * This program is free software: you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation, either version 3 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | * 29 | * For further information please contact. 30 | * ilmari.heikkinen@gmail.com 31 | * 32 | */ 33 | 34 | 35 | 36 | 37 | 38 | /** 39 | * マーカの周辺領域からビットマップを取得する方法を提供します。 40 | * 比較的負荷が大きいので、連続してパターンを取得し続ける用途には向いていません。 41 | * 42 | */ 43 | TransformedBitmapPickup = ASKlass('TransformedBitmapPickup', NyARColorPatt_Perspective_O2, 44 | { 45 | _work_points : NyARIntPoint2d.createArray(4), 46 | _ref_perspective : null, 47 | /** 48 | * 49 | * @param i_width 50 | * 取得するビットマップの幅 51 | * @param i_height 52 | * 取得するビットマップの解像度 53 | * @param i_resolution 54 | * resolution of reading pixel per point. ---- 取得時の解像度。高解像度のときは1を指定してください。低解像度のときは2以上を指定します。 55 | */ 56 | TransformedBitmapPickup : function(i_ref_cparam,i_width,i_height,i_resolution) 57 | { 58 | NyARColorPatt_Perspective_O2.initialize.call(this,i_width, i_height, i_resolution, 0); 59 | this._ref_perspective = i_ref_cparam; 60 | } 61 | /** 62 | * This ,retrieves bitmap from the area defined by RECT : function(i_l,i_t,i_r,i_b) above transform matrix i_base_mat. 63 | * ---- 64 | * この関数は、basementで示される平面のAで定義される領域から、ビットマップを読み出します。 65 | * 例えば、8cmマーカでRECT(i_l,i_t,i_r,i_b)に-40,0,0,-40.0を指定すると、マーカの左下部分の画像を抽出します。 66 | * 67 | * マーカから離れた場所になるほど、また、マーカの鉛直方向から外れるほど誤差が大きくなります。 68 | * @param i_src_imege 69 | * 詠み出し元の画像を指定します。 70 | * @param i_l 71 | * 基準点からの左上の相対座標(x)を指定します。 72 | * @param i_t 73 | * 基準点からの左上の相対座標(y)を指定します。 74 | * @param i_r 75 | * 基準点からの右下の相対座標(x)を指定します。 76 | * @param i_b 77 | * 基準点からの右下の相対座標(y)を指定します。 78 | * @param i_base_mat 79 | * @return 画像の取得の成否を返す。 80 | */ 81 | ,pickupImage2d : function(i_src_imege,i_l,i_t,i_r,i_b,i_base_mat) 82 | { 83 | var cp00, cp01, cp02, cp11, cp12; 84 | cp00 = this._ref_perspective.m00; 85 | cp01 = this._ref_perspective.m01; 86 | cp02 = this._ref_perspective.m02; 87 | cp11 = this._ref_perspective.m11; 88 | cp12 = this._ref_perspective.m12; 89 | //マーカと同一平面上にある矩形の4個の頂点を座標変換して、射影変換して画面上の 90 | //頂点を計算する。 91 | //[hX,hY,h]=[P][RT][x,y,z] 92 | //出力先 93 | var poinsts = this._work_points; 94 | var yt0,yt1,yt2; 95 | var x3, y3, z3; 96 | var m00=i_base_mat.m00; 97 | var m10=i_base_mat.m10; 98 | var m20=i_base_mat.m20; 99 | //yとtの要素を先に計算 100 | yt0=i_base_mat.m01 * i_t+i_base_mat.m03; 101 | yt1=i_base_mat.m11 * i_t+i_base_mat.m13; 102 | yt2=i_base_mat.m21 * i_t+i_base_mat.m23; 103 | // l,t 104 | x3 = m00 * i_l + yt0; 105 | y3 = m10 * i_l + yt1; 106 | z3 = m20 * i_l + yt2; 107 | poinsts[0].x = toInt ((x3 * cp00 + y3 * cp01 + z3 * cp02) / z3); 108 | poinsts[0].y = toInt ((y3 * cp11 + z3 * cp12) / z3); 109 | // r,t 110 | x3 = m00 * i_r + yt0; 111 | y3 = m10 * i_r + yt1; 112 | z3 = m20 * i_r + yt2; 113 | poinsts[1].x = toInt ((x3 * cp00 + y3 * cp01 + z3 * cp02) / z3); 114 | poinsts[1].y = toInt ((y3 * cp11 + z3 * cp12) / z3); 115 | //yとtの要素を先に計算 116 | yt0=i_base_mat.m01 * i_b+i_base_mat.m03; 117 | yt1=i_base_mat.m11 * i_b+i_base_mat.m13; 118 | yt2=i_base_mat.m21 * i_b+i_base_mat.m23; 119 | // r,b 120 | x3 = m00 * i_r + yt0; 121 | y3 = m10 * i_r + yt1; 122 | z3 = m20 * i_r + yt2; 123 | poinsts[2].x = toInt ((x3 * cp00 + y3 * cp01 + z3 * cp02) / z3); 124 | poinsts[2].y = toInt ((y3 * cp11 + z3 * cp12) / z3); 125 | // l,b 126 | x3 = m00 * i_l + yt0; 127 | y3 = m10 * i_l + yt1; 128 | z3 = m20 * i_l + yt2; 129 | poinsts[3].x = toInt ((x3 * cp00 + y3 * cp01 + z3 * cp02) / z3); 130 | poinsts[3].y = toInt ((y3 * cp11 + z3 * cp12) / z3); 131 | return this.pickFromRaster(i_src_imege, poinsts); 132 | } 133 | }) 134 | --------------------------------------------------------------------------------