123456789101112131415161718192021222324252627282930313233343536373839404142 |
- const psqlDB = require("../psql.service");
- class FaceService{
- async getSameReportList(feat68,limit){
- limit = limit || 10;
- // cosine_similarity
- let sql = `
- select "objectId" as id,"title","photo","createdAt", array_agg(item)::vector(128) <=> $1::vector(128) as cos
- from (
- SELECT *, jsonb_array_elements("feat68")::float AS item from (
- SELECT "objectId","photo","title","feat68","createdAt"
- FROM "FaceReport"
- WHERE "feat68" is not null
- ORDER BY "createdAt" DESC
- ) as rt1
- ) as rt
- GROUP BY "objectId","title",rt."photo","createdAt"
- ORDER BY cos limit ${limit};
- `
- let params = [feat68]
- let result
- try{
- result = await psqlDB.any(sql,params)
- console.log(result)
- }catch(err){
- console.error(err)
- }
- // 人物不同 0.08 0.09 0.06 0.059
- // 人物不同 长相像 0.046 0.045 0.043 0.039
- // 人物相同 仰角/光照有变化 0.03846
- // 人物相同 > 0.0214 0.0188 0.00218 0.038 0.023
- // result = result.filter(item=>item.cos<0.0385 && item.id!=report.id)
- // result.sort((a,b)=>a.createdAt-b.createdAt)
- if(result?.length>0){
- console.log(result)
- }
- return result
- }
- }
- module.exports.FaceService = FaceService
|