@@ -24,8 +24,6 @@ discard block |
||
| 24 | 24 | namespace OCA\FaceRecognition\BackgroundJob; |
| 25 | 25 | |
| 26 | 26 | use OCA\FaceRecognition\AppInfo\Application; |
| 27 | -use OCA\FaceRecognition\Helper\Requirements; |
|
| 28 | - |
|
| 29 | 27 | use OCA\FaceRecognition\BackgroundJob\Tasks\CheckCronTask; |
| 30 | 28 | use OCA\FaceRecognition\BackgroundJob\Tasks\CheckRequirementsTask; |
| 31 | 29 | use OCA\FaceRecognition\BackgroundJob\Tasks\LockTask; |
@@ -35,8 +33,6 @@ discard block |
||
| 35 | 33 | use OCA\FaceRecognition\BackgroundJob\Tasks\ImageProcessingTask; |
| 36 | 34 | use OCA\FaceRecognition\BackgroundJob\Tasks\UnlockTask; |
| 37 | 35 | |
| 38 | -use Symfony\Component\Console\Output\OutputInterface; |
|
| 39 | - |
|
| 40 | 36 | /** |
| 41 | 37 | * Background service. Both command and cron job are calling this service for long-running background operations. |
| 42 | 38 | * Background processing for face recognition is comprised of several steps, called tasks. Each task is independent, |
@@ -24,7 +24,6 @@ |
||
| 24 | 24 | namespace OCA\FaceRecognition\BackgroundJob; |
| 25 | 25 | |
| 26 | 26 | use OCP\ILogger; |
| 27 | - |
|
| 28 | 27 | use Symfony\Component\Console\Output\OutputInterface; |
| 29 | 28 | |
| 30 | 29 | /** |
@@ -25,10 +25,8 @@ |
||
| 25 | 25 | |
| 26 | 26 | use OCP\IConfig; |
| 27 | 27 | use OCP\IUser; |
| 28 | - |
|
| 29 | 28 | use OCP\Files\File; |
| 30 | 29 | use OCP\Files\Folder; |
| 31 | - |
|
| 32 | 30 | use OCA\FaceRecognition\BackgroundJob\FaceRecognitionBackgroundTask; |
| 33 | 31 | use OCA\FaceRecognition\BackgroundJob\FaceRecognitionContext; |
| 34 | 32 | use OCA\FaceRecognition\Db\Image; |
@@ -24,13 +24,9 @@ |
||
| 24 | 24 | namespace OCA\FaceRecognition\BackgroundJob\Tasks; |
| 25 | 25 | |
| 26 | 26 | use OC_Image; |
| 27 | - |
|
| 28 | 27 | use OCP\Files\File; |
| 29 | -use OCP\Files\Folder; |
|
| 30 | 28 | use OCP\IConfig; |
| 31 | 29 | use OCP\ITempManager; |
| 32 | -use OCP\IUser; |
|
| 33 | - |
|
| 34 | 30 | use OCA\FaceRecognition\BackgroundJob\FaceRecognitionBackgroundTask; |
| 35 | 31 | use OCA\FaceRecognition\BackgroundJob\FaceRecognitionContext; |
| 36 | 32 | use OCA\FaceRecognition\Db\FaceNew; |
@@ -273,7 +273,7 @@ |
||
| 273 | 273 | * |
| 274 | 274 | * @param \FaceLandmarkDetection $fld Landmark detection model |
| 275 | 275 | * @param \FaceRecognition $fr Face recognition model |
| 276 | - * @param ImageProcessingContext Image processing context |
|
| 276 | + * @param ImageProcessingContext ImageProcessingContext processing context |
|
| 277 | 277 | */ |
| 278 | 278 | private function populateDescriptors(\FaceLandmarkDetection $fld, \FaceRecognition $fr, ImageProcessingContext $imageProcessingContext) { |
| 279 | 279 | $faces = $imageProcessingContext->getFaces(); |
@@ -274,10 +274,16 @@ |
||
| 274 | 274 | $this->output->writeln(count($facesFound).' faces(s) found.'); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | + /** |
|
| 278 | + * @param integer $progress |
|
| 279 | + */ |
|
| 277 | 280 | private function updateProgress($progress) { |
| 278 | 281 | $this->config->setAppValue('facerecognition', 'queue-done', $progress); |
| 279 | 282 | } |
| 280 | 283 | |
| 284 | + /** |
|
| 285 | + * @param integer $time |
|
| 286 | + */ |
|
| 281 | 287 | private function setStartTime($time) { |
| 282 | 288 | $this->config->setAppValue('facerecognition', 'starttime', $time); |
| 283 | 289 | } |
@@ -26,21 +26,16 @@ |
||
| 26 | 26 | namespace OCA\FaceRecognition\Command; |
| 27 | 27 | |
| 28 | 28 | use OCP\Encryption\IManager; |
| 29 | -use OCP\Files\File; |
|
| 30 | -use OCP\Files\Folder; |
|
| 31 | -use OCP\Files\IAppData; |
|
| 32 | 29 | use OCP\Files\IRootFolder; |
| 33 | 30 | use OCP\App\IAppManager; |
| 34 | 31 | use OCP\Files\NotFoundException; |
| 35 | 32 | use OCP\IConfig; |
| 36 | -use OCP\IDateTimeFormatter; |
|
| 37 | 33 | use OCP\IUser; |
| 38 | 34 | use OCP\IUserManager; |
| 39 | 35 | use Symfony\Component\Console\Command\Command; |
| 40 | 36 | use Symfony\Component\Console\Input\InputArgument; |
| 41 | 37 | use Symfony\Component\Console\Input\InputInterface; |
| 42 | 38 | use Symfony\Component\Console\Output\OutputInterface; |
| 43 | - |
|
| 44 | 39 | use OCA\FaceRecognition\Db\Face; |
| 45 | 40 | use OCA\FaceRecognition\Db\FaceMapper; |
| 46 | 41 | use OCA\FaceRecognition\Helper\Requirements; |
@@ -25,15 +25,9 @@ |
||
| 25 | 25 | |
| 26 | 26 | use OCP\App\IAppManager; |
| 27 | 27 | use OCP\Encryption\IManager; |
| 28 | - |
|
| 29 | 28 | use Symfony\Component\Console\Command\Command; |
| 30 | -use Symfony\Component\Console\Input\InputArgument; |
|
| 31 | 29 | use Symfony\Component\Console\Input\InputInterface; |
| 32 | 30 | use Symfony\Component\Console\Output\OutputInterface; |
| 33 | - |
|
| 34 | -use OCA\FaceRecognition\Db\Face; |
|
| 35 | -use OCA\FaceRecognition\Db\FaceMapper; |
|
| 36 | - |
|
| 37 | 31 | use OCA\FaceRecognition\Helper\Requirements; |
| 38 | 32 | |
| 39 | 33 | class Check extends Command { |
@@ -29,7 +29,6 @@ discard block |
||
| 29 | 29 | use OCP\Files\File; |
| 30 | 30 | use OCP\Files\Folder; |
| 31 | 31 | use OCP\Files\IRootFolder; |
| 32 | -use OCP\Files\NotFoundException; |
|
| 33 | 32 | use OCP\IConfig; |
| 34 | 33 | use OCP\IUser; |
| 35 | 34 | use OCP\IUserManager; |
@@ -37,7 +36,6 @@ discard block |
||
| 37 | 36 | use Symfony\Component\Console\Input\InputArgument; |
| 38 | 37 | use Symfony\Component\Console\Input\InputInterface; |
| 39 | 38 | use Symfony\Component\Console\Output\OutputInterface; |
| 40 | - |
|
| 41 | 39 | use OCA\FaceRecognition\Db\Face; |
| 42 | 40 | use OCA\FaceRecognition\Db\FaceMapper; |
| 43 | 41 | use OCA\FaceRecognition\Helper\Requirements; |
@@ -26,10 +26,7 @@ discard block |
||
| 26 | 26 | namespace OCA\FaceRecognition\Command; |
| 27 | 27 | |
| 28 | 28 | use OCP\Encryption\IManager; |
| 29 | -use OCP\Files\File; |
|
| 30 | -use OCP\Files\Folder; |
|
| 31 | 29 | use OCP\Files\IRootFolder; |
| 32 | -use OCP\Files\NotFoundException; |
|
| 33 | 30 | use OCP\IConfig; |
| 34 | 31 | use OCP\IUser; |
| 35 | 32 | use OCP\IUserManager; |
@@ -37,8 +34,6 @@ discard block |
||
| 37 | 34 | use Symfony\Component\Console\Input\InputArgument; |
| 38 | 35 | use Symfony\Component\Console\Input\InputInterface; |
| 39 | 36 | use Symfony\Component\Console\Output\OutputInterface; |
| 40 | - |
|
| 41 | -use OCA\FaceRecognition\Db\Face; |
|
| 42 | 37 | use OCA\FaceRecognition\Db\FaceMapper; |
| 43 | 38 | use OCA\FaceRecognition\Helper\Euclidean; |
| 44 | 39 | |
@@ -3,8 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use OCP\IDBConnection; |
| 5 | 5 | use OCP\AppFramework\Db\Mapper; |
| 6 | -use OCP\AppFramework\Db\DoesNotExistException; |
|
| 7 | -use OCP\DB\QueryBuilder\IQueryBuilder; |
|
| 8 | 6 | |
| 9 | 7 | class FaceMapper extends Mapper { |
| 10 | 8 | |
@@ -22,16 +22,27 @@ discard block |
||
| 22 | 22 | return $this->findEntities($sql, [$userId]); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $userId |
|
| 27 | + * @param integer $limit |
|
| 28 | + * @param integer $offset |
|
| 29 | + */ |
|
| 25 | 30 | public function findAllQueued($userId, $limit = null, $offset = null) { |
| 26 | 31 | $sql = 'SELECT * FROM *PREFIX*face_recognition WHERE uid = ? AND distance = -1 AND encoding IS NULL'; |
| 27 | 32 | return $this->findEntities($sql, [$userId], $limit, $offset); |
| 28 | 33 | } |
| 29 | 34 | |
| 35 | + /** |
|
| 36 | + * @param string $userId |
|
| 37 | + */ |
|
| 30 | 38 | public function findAllKnown($userId) { |
| 31 | 39 | $sql = 'SELECT * FROM *PREFIX*face_recognition WHERE uid = ? AND distance = 0 AND encoding IS NOT NULL'; |
| 32 | 40 | return $this->findEntities($sql, [$userId]); |
| 33 | 41 | } |
| 34 | 42 | |
| 43 | + /** |
|
| 44 | + * @param string $userId |
|
| 45 | + */ |
|
| 35 | 46 | public function findAllUnknown($userId) { |
| 36 | 47 | $sql = 'SELECT * FROM *PREFIX*face_recognition WHERE uid = ? AND distance > 0 AND encoding IS NOT NULL'; |
| 37 | 48 | return $this->findEntities($sql, [$userId]); |
@@ -42,6 +53,9 @@ discard block |
||
| 42 | 53 | return $this->findEntities($sql, [$userId]); |
| 43 | 54 | } |
| 44 | 55 | |
| 56 | + /** |
|
| 57 | + * @param integer $limit |
|
| 58 | + */ |
|
| 45 | 59 | public function findAllNamed($userId, $query, $limit = null, $offset = null) { |
| 46 | 60 | $sql = 'SELECT id, name, distance FROM *PREFIX*face_recognition WHERE uid = ? AND encoding IS NOT NULL AND LOWER(name) LIKE LOWER(?)'; |
| 47 | 61 | return $this->findEntities($sql, [$userId, $query], $limit, $offset); |
@@ -57,11 +71,17 @@ discard block |
||
| 57 | 71 | return $this->findEntities($sql, [$userId]); |
| 58 | 72 | } |
| 59 | 73 | |
| 74 | + /** |
|
| 75 | + * @param integer $fileId |
|
| 76 | + */ |
|
| 60 | 77 | public function findNewFile($userId, $fileId) { |
| 61 | 78 | $sql = 'SELECT * FROM *PREFIX*face_recognition WHERE uid = ? AND file = ? AND distance = -1 AND encoding IS NULL'; |
| 62 | 79 | return $this->findEntities($sql, [$userId, $fileId]); |
| 63 | 80 | } |
| 64 | 81 | |
| 82 | + /** |
|
| 83 | + * @param integer $fileId |
|
| 84 | + */ |
|
| 65 | 85 | public function findFile($userId, $fileId) { |
| 66 | 86 | $sql = 'SELECT * FROM *PREFIX*face_recognition WHERE uid = ? AND file = ?'; |
| 67 | 87 | return $this->findEntities($sql, [$userId, $fileId]); |
@@ -78,6 +98,9 @@ discard block |
||
| 78 | 98 | return true; |
| 79 | 99 | } |
| 80 | 100 | |
| 101 | + /** |
|
| 102 | + * @param string $userId |
|
| 103 | + */ |
|
| 81 | 104 | public function countUserQueue($userId) { |
| 82 | 105 | $sql = 'SELECT count(*) AS ct FROM *PREFIX*face_recognition WHERE uid = ? AND distance = -1 AND encoding IS NULL'; |
| 83 | 106 | $query = \OCP\DB::prepare($sql); |