summaryrefslogtreecommitdiff
path: root/utils/raspberrypi/ctt/ctt_tools.py
AgeCommit message (Collapse)Author
2021-08-03utils: raspberrypi: ctt: Fix namespace for sklearn NearestCentroid functionDavid Plowman
Starting in version 0.22, the NearestCentroid function is only available in the sklearn.neighbors namespace, when it was previously available in both the sklearn.neighbors.nearest_centroid and sklearn.neighbors namespaces. Use sklearn.neighbors as it works on all versions of sklearn. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-05-13utils: raspberrypi: ctt: Fix pycodestyle E302Laurent Pinchart
E302 expected 2 blank lines, found 0 Note that issues are still flagged, due to the use of docstrings as multi-lines comments. This will be addressed separately. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2020-05-13utils: raspberrypi: ctt: Fix pycodestyle E305Laurent Pinchart
E305 expected 2 blank lines after class or function definition Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2020-05-13utils: raspberrypi: ctt: Fix pycodestyle E721Laurent Pinchart
E721 do not compare types, use 'isinstance()' Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2020-05-13utils: raspberrypi: ctt: Fix pycodestyle E116 and E117Laurent Pinchart
E116 unexpected indentation (comment) E117 over-indented (comment) Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2020-05-13utils: raspberrypi: ctt: Fix pycodestyle E711 and E712Laurent Pinchart
E711 comparison to None should be 'if cond is None:' E711 comparison to None should be 'if cond is not None:' E712 comparison to False should be 'if cond is False:' or 'if not cond:' E712 comparison to True should be 'if cond is True:' or 'if cond:' Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2020-05-13utils: raspberrypi: ctt: Fix pycodestyle E228Laurent Pinchart
E228 missing whitespace around modulo operator Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2020-05-13utils: raspberrypi: ctt: Fix pycodestyle E211Laurent Pinchart
E211 whitespace before '[' Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2020-05-13utils: raspberrypi: ctt: Fix pycodestyle E231Laurent Pinchart
E231 missing whitespace after ',' E231 missing whitespace after ':' Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2020-05-11libcamera: utils: Raspberry Pi Camera Tuning ToolNaushir Patuck
Initial implementation of the Raspberry Pi (BCM2835) Camera Tuning Tool. All code is licensed under the BSD-2-Clause terms. Copyright (c) 2019-2020 Raspberry Pi Trading Ltd. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
kwc">FrameMetadata::FrameSuccess) return; completeBuffersCount_++; } void requestComplete(Request *request) { if (request->status() != Request::RequestComplete) return; const Request::BufferMap &buffers = request->buffers(); completeRequestsCount_++; /* Create a new request. */ const Stream *stream = buffers.begin()->first; FrameBuffer *buffer = buffers.begin()->second; request = camera_->createRequest(); request->addBuffer(stream, buffer); camera_->queueRequest(request); } int init() override { if (status_ != TestPass) return status_; config_ = camera_->generateConfiguration({ StreamRole::VideoRecording }); if (!config_ || config_->size() != 1) { cout << "Failed to generate default configuration" << endl; return TestFail; } allocator_ = new FrameBufferAllocator(camera_); return TestPass; } void cleanup() override { delete allocator_; } int run() override { StreamConfiguration &cfg = config_->at(0); if (camera_->acquire()) { cout << "Failed to acquire the camera" << endl; return TestFail; } if (camera_->configure(config_.get())) { cout << "Failed to set default configuration" << endl; return TestFail; } Stream *stream = cfg.stream(); int ret = allocator_->allocate(stream); if (ret < 0) return TestFail; std::vector<Request *> requests; for (const std::unique_ptr<FrameBuffer> &buffer : allocator_->buffers(stream)) { Request *request = camera_->createRequest(); if (!request) { cout << "Failed to create request" << endl; return TestFail; } if (request->addBuffer(stream, buffer.get())) { cout << "Failed to associating buffer with request" << endl; return TestFail; } requests.push_back(request); } completeRequestsCount_ = 0; completeBuffersCount_ = 0; camera_->bufferCompleted.connect(this, &Capture::bufferComplete); camera_->requestCompleted.connect(this, &Capture::requestComplete); if (camera_->start()) { cout << "Failed to start camera" << endl; return TestFail; } for (Request *request : requests) { if (camera_->queueRequest(request)) { cout << "Failed to queue request" << endl; return TestFail; } } EventDispatcher *dispatcher = cm_->eventDispatcher(); Timer timer; timer.start(1000); while (timer.isRunning()) dispatcher->processEvents(); unsigned int nbuffers = allocator_->buffers(stream).size(); if (completeRequestsCount_ <= nbuffers * 2) { cout << "Failed to capture enough frames (got " << completeRequestsCount_ << " expected at least " << nbuffers * 2 << ")" << endl; return TestFail; } if (completeRequestsCount_ != completeBuffersCount_) { cout << "Number of completed buffers and requests differ" << endl; return TestFail; } if (camera_->stop()) { cout << "Failed to stop camera" << endl; return TestFail; } return TestPass; } std::unique_ptr<CameraConfiguration> config_; FrameBufferAllocator *allocator_; }; } /* namespace */ TEST_REGISTER(Capture);