[141] | 1 |
|
---|
| 2 | // Includes, project.
|
---|
| 3 | #include "CameraViewerComponent.hpp"
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | // Includes, pacpus.
|
---|
| 7 | #include <Pacpus/kernel/ComponentFactory.h>
|
---|
| 8 | #include <Pacpus/kernel/Log.h>
|
---|
| 9 | #include <Pacpus/kernel/DbiteFileTypes.h>
|
---|
| 10 | #include <Pacpus/kernel/DbiteException.h>
|
---|
| 11 |
|
---|
| 12 | // Includes, standard.
|
---|
| 13 | #include <stdexcept>
|
---|
| 14 | #include <QMetaType>
|
---|
| 15 | #include <iostream>
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | using namespace pacpus;
|
---|
| 19 |
|
---|
| 20 | // Declare the logger and register the new component.
|
---|
| 21 | //DECLARE_STATIC_LOGGER("pacpus.component.vislabCamera")
|
---|
| 22 | //REGISTER_COMPONENT(CameraViewerComponent, "Camera");
|
---|
| 23 |
|
---|
| 24 | ComponentFactory<CameraViewerComponent> sFactory("CameraViewerComponent");
|
---|
| 25 |
|
---|
| 26 | CameraViewerComponent::CameraViewerComponent(QString const& name)
|
---|
| 27 | :ComponentBase(name)
|
---|
| 28 | {
|
---|
| 29 |
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | CameraViewerComponent::~CameraViewerComponent()
|
---|
| 33 | {
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | void
|
---|
| 39 | CameraViewerComponent::stopActivity()
|
---|
| 40 | {
|
---|
| 41 |
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | void
|
---|
| 45 | CameraViewerComponent::startActivity()
|
---|
| 46 | {
|
---|
| 47 | qRegisterMetaType<cv::Mat>("cv::Mat");
|
---|
| 48 | connect(this, SIGNAL(doDisplay(cv::Mat)), SLOT(DisplayFrame(cv::Mat)));
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | ComponentBase::COMPONENT_CONFIGURATION
|
---|
| 52 | CameraViewerComponent::configureComponent(XmlComponentConfig config)
|
---|
| 53 | {
|
---|
| 54 | return ComponentBase::CONFIGURED_OK;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | void CameraViewerComponent::addInputs()
|
---|
| 58 | {
|
---|
| 59 | addInput<cv::Mat, CameraViewerComponent>("image", &CameraViewerComponent::process);
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | void CameraViewerComponent::DisplayFrame(cv::Mat const& frame)
|
---|
| 63 | {
|
---|
| 64 | //getchar();
|
---|
| 65 | //std::cout << getName().toStdString() << std::endl;
|
---|
| 66 | cv::imshow(getName().toStdString(), frame);
|
---|
| 67 | //cv::imshow("Image", frame);
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | /*! process function from the Display class with a cv:Mat parameter
|
---|
| 71 | Emit the signal to diplay the frame
|
---|
| 72 | */
|
---|
| 73 | void CameraViewerComponent::process(cv::Mat const& frame)
|
---|
| 74 | {
|
---|
| 75 | emit doDisplay(frame);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 |
|
---|