This commit is contained in:
qwertyforce 2020-11-04 22:00:20 +03:00
parent 06af8b34c7
commit b4246fdf22
3 changed files with 77 additions and 3 deletions

48
package-lock.json generated
View File

@ -4039,8 +4039,7 @@
"callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"dev": true
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="
},
"camelcase": {
"version": "5.3.1",
@ -5504,6 +5503,12 @@
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
"dev": true
},
"esm": {
"version": "3.2.25",
"resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz",
"integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==",
"optional": true
},
"espree": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz",
@ -6996,6 +7001,14 @@
"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
"dev": true
},
"is-observable": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-observable/-/is-observable-1.1.0.tgz",
"integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==",
"requires": {
"symbol-observable": "^1.1.0"
}
},
"is-path-inside": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.2.tgz",
@ -10041,6 +10054,11 @@
"has": "^1.0.3"
}
},
"observable-fns": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/observable-fns/-/observable-fns-0.5.1.tgz",
"integrity": "sha512-wf7g4Jpo1Wt2KIqZKLGeiuLOEMqpaOZ5gJn7DmSdqXgTdxRwSdBhWegQQpPteQ2gZvzCKqNNpwb853wcpA0j7A=="
},
"on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
@ -12232,6 +12250,11 @@
}
}
},
"symbol-observable": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
},
"symbol-tree": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
@ -12537,6 +12560,18 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"threads": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/threads/-/threads-1.6.3.tgz",
"integrity": "sha512-tKwFIWRgfAT85KGkrpDt2jWPO8IVH0sLNfB/pXad/VW9eUIY2Zlz+QyeizypXhPHv9IHfqRzvk2t3mPw+imhWw==",
"requires": {
"callsites": "^3.1.0",
"debug": "^4.1.1",
"is-observable": "^1.1.0",
"observable-fns": "^0.5.1",
"tiny-worker": ">= 2"
}
},
"throat": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz",
@ -12565,6 +12600,15 @@
"resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz",
"integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA=="
},
"tiny-worker": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/tiny-worker/-/tiny-worker-2.3.0.tgz",
"integrity": "sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==",
"optional": true,
"requires": {
"esm": "^3.2.25"
}
},
"tmpl": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz",

View File

@ -40,7 +40,8 @@
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-photo-gallery": "^8.0.0",
"sharp": "^0.26.1"
"sharp": "^0.26.1",
"threads": "^1.6.3"
},
"devDependencies": {
"@types/bcrypt": "^3.0.0",

View File

@ -0,0 +1,29 @@
import * as cv from 'opencv4nodejs'
import path from 'path';
import db_ops from '../helpers/db_ops'
import config from '../../config/config'
const detector=new cv.SIFTDetector({ nFeatures: 400 })
const PATH_TO_IMAGES = path.join(config.root_path, 'public', 'images')
async function calculate_color_hist(){
const images = await db_ops.image_ops.get_all_images()
for(const image of images){
const check_if_already_calculated= await db_ops.image_search.get_sift_features_by_id(image.id)
if(check_if_already_calculated.length!==0){
continue
}
console.log(image.id)
const img = await cv.imreadAsync(`${PATH_TO_IMAGES}/${image.id}.${image.file_ext}`);
const keyPoints = await detector.detectAsync(img);
const descriptors = await detector.computeAsync(img, keyPoints);
descriptors.release()
img.release()
const descriptors_as_array=descriptors.getDataAsArray()
await db_ops.image_search.add_sift_features_by_id(image.id,descriptors_as_array)
}
}
async function run() {
await calculate_color_hist()
}
run()