-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command: recognize:reset-face-clusters
Signed-off-by: Marcel Klehr <[email protected]>
- Loading branch information
1 parent
75e1641
commit bae933d
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/* | ||
* Copyright (c) 2022 The Recognize contributors. | ||
* This file is licensed under the Affero General Public License version 3 or later. See the COPYING file. | ||
*/ | ||
|
||
namespace OCA\Recognize\Command; | ||
|
||
use OCA\Recognize\Db\FaceClusterMapper; | ||
use OCA\Recognize\Db\FaceDetectionMapper; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class ResetFaceClusters extends Command { | ||
private FaceDetectionMapper $faceDetectionMapper; | ||
private FaceClusterMapper $clusterMapper; | ||
|
||
public function __construct(FaceDetectionMapper $faceDetectionMapper, FaceClusterMapper $clusterMapper) { | ||
parent::__construct(); | ||
$this->faceDetectionMapper = $faceDetectionMapper; | ||
$this->clusterMapper = $clusterMapper; | ||
} | ||
|
||
/** | ||
* Configure the command | ||
* | ||
* @return void | ||
*/ | ||
protected function configure() { | ||
$this->setName('recognize:reset-face-clusters') | ||
->setDescription('Remove all face clusters. Detected face will stay intact.'); | ||
} | ||
|
||
/** | ||
* Execute the command | ||
* | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int { | ||
try { | ||
$this->clusterMapper->deleteAll(); | ||
$this->faceDetectionMapper->removeAllClusters(); | ||
} catch (\Exception $ex) { | ||
$output->writeln('<error>Failed to reset face clusters</error>'); | ||
$output->writeln($ex->getMessage()); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters