recognize: add faceid to response
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/504/head
parent
1ef3f576b0
commit
8044298ab8
|
@ -211,7 +211,7 @@ class DaysController extends ApiBase
|
||||||
|
|
||||||
// Filter only for one face on Recognize
|
// Filter only for one face on Recognize
|
||||||
if (($recognize = $this->request->getParam('recognize')) && $this->recognizeIsEnabled()) {
|
if (($recognize = $this->request->getParam('recognize')) && $this->recognizeIsEnabled()) {
|
||||||
$transforms[] = [$this->timelineQuery, 'transformPeopleRecognitionFilter', $recognize];
|
$transforms[] = [$this->timelineQuery, 'transformPeopleRecognitionFilter', $recognize, $aggregateOnly];
|
||||||
|
|
||||||
$faceRect = $this->request->getParam('facerect');
|
$faceRect = $this->request->getParam('facerect');
|
||||||
if ($faceRect && !$aggregateOnly) {
|
if ($faceRect && !$aggregateOnly) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ trait TimelineQueryPeopleRecognize
|
||||||
{
|
{
|
||||||
protected IDBConnection $connection;
|
protected IDBConnection $connection;
|
||||||
|
|
||||||
public function transformPeopleRecognitionFilter(IQueryBuilder &$query, string $userId, string $faceStr)
|
public function transformPeopleRecognitionFilter(IQueryBuilder &$query, string $userId, string $faceStr, bool $isAggregate)
|
||||||
{
|
{
|
||||||
// Get name and uid of face user
|
// Get name and uid of face user
|
||||||
$faceNames = explode('/', $faceStr);
|
$faceNames = explode('/', $faceStr);
|
||||||
|
@ -21,17 +21,28 @@ trait TimelineQueryPeopleRecognize
|
||||||
$faceUid = $faceNames[0];
|
$faceUid = $faceNames[0];
|
||||||
$faceName = $faceNames[1];
|
$faceName = $faceNames[1];
|
||||||
|
|
||||||
|
if (!$isAggregate) {
|
||||||
|
// Multiple detections for the same image
|
||||||
|
$query->addSelect('rfd.id AS faceid');
|
||||||
|
}
|
||||||
|
|
||||||
// Join with cluster
|
// Join with cluster
|
||||||
$nameField = is_numeric($faceName) ? 'rfc.id' : 'rfc.title';
|
$clusterQuery = null;
|
||||||
$query->innerJoin('m', 'recognize_face_clusters', 'rfc', $query->expr()->andX(
|
if ($faceName !== 'NULL') {
|
||||||
$query->expr()->eq('rfc.user_id', $query->createNamedParameter($faceUid)),
|
$nameField = is_numeric($faceName) ? 'rfc.id' : 'rfc.title';
|
||||||
$query->expr()->eq($nameField, $query->createNamedParameter($faceName)),
|
$query->innerJoin('m', 'recognize_face_clusters', 'rfc', $query->expr()->andX(
|
||||||
));
|
$query->expr()->eq('rfc.user_id', $query->createNamedParameter($faceUid)),
|
||||||
|
$query->expr()->eq($nameField, $query->createNamedParameter($faceName)),
|
||||||
|
));
|
||||||
|
$clusterQuery = $query->expr()->eq('rfd.cluster_id', 'rfc.id');
|
||||||
|
} else {
|
||||||
|
$clusterQuery = $query->expr()->isNull('rfd.cluster_id');
|
||||||
|
}
|
||||||
|
|
||||||
// Join with detections
|
// Join with detections
|
||||||
$query->innerJoin('m', 'recognize_face_detections', 'rfd', $query->expr()->andX(
|
$query->innerJoin('m', 'recognize_face_detections', 'rfd', $query->expr()->andX(
|
||||||
$query->expr()->eq('rfd.file_id', 'm.fileid'),
|
$query->expr()->eq('rfd.file_id', 'm.fileid'),
|
||||||
$query->expr()->eq('rfd.cluster_id', 'rfc.id'),
|
$clusterQuery,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1189,13 +1189,14 @@ export default defineComponent({
|
||||||
// Duplicate detection.
|
// Duplicate detection.
|
||||||
// These may be valid, e.g. in face rects. All we need to have
|
// These may be valid, e.g. in face rects. All we need to have
|
||||||
// is a unique Vue key for the v-for loop.
|
// is a unique Vue key for the v-for loop.
|
||||||
if (seen.has(photo.fileid)) {
|
const key = photo.faceid || photo.fileid;
|
||||||
const val = seen.get(photo.fileid);
|
if (seen.has(key)) {
|
||||||
photo.key = `${photo.fileid}-${val}`;
|
const val = seen.get(key);
|
||||||
seen.set(photo.fileid, val + 1);
|
photo.key = `${key}-${val}`;
|
||||||
|
seen.set(key, val + 1);
|
||||||
} else {
|
} else {
|
||||||
photo.key = `${photo.fileid}`;
|
photo.key = `${key}`;
|
||||||
seen.set(photo.fileid, 1);
|
seen.set(key, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add photo to row
|
// Add photo to row
|
||||||
|
|
|
@ -92,6 +92,8 @@ export type IPhoto = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Face detection ID */
|
||||||
|
faceid?: number;
|
||||||
/** Face dimensions */
|
/** Face dimensions */
|
||||||
facerect?: IFaceRect;
|
facerect?: IFaceRect;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue