Add Simple Image Processor
This commit is contained in:
3
.vscode/c_cpp_properties.json
vendored
3
.vscode/c_cpp_properties.json
vendored
@@ -4,7 +4,8 @@
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"/opt/pleora/ebus_sdk/Ubuntu-x86_64/include/**"
|
||||
"/opt/pleora/ebus_sdk/Ubuntu-x86_64/include/**",
|
||||
"/usr/local/include/opencv4/**"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
|
||||
@@ -14,6 +14,7 @@ include_directories(
|
||||
add_executable( FaultFinder
|
||||
FaultFinder.cpp
|
||||
StreamManager.cpp
|
||||
ImageProcessor.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( FaultFinder
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "StreamManager.hpp"
|
||||
#include "ImageProcessor.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
StreamManager mgr;
|
||||
ImageProcessor processor;
|
||||
StreamManager manager;
|
||||
PvString lConnectionID;
|
||||
|
||||
// If no devies are found, exit.
|
||||
if (mgr.FindDevice(&lConnectionID).IsFailure())
|
||||
if (manager.FindDevice(&lConnectionID).IsFailure())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mgr.ConnectToDevice(lConnectionID).IsFailure())
|
||||
if (manager.ConnectToDevice(lConnectionID).IsFailure())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
mgr.OpenStream(lConnectionID);
|
||||
manager.OpenStream(lConnectionID);
|
||||
|
||||
mgr.AcquireImages();
|
||||
manager.AcquireImages(processor);
|
||||
|
||||
mgr.Disconnect();
|
||||
manager.Disconnect();
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
ImageProcessor.cpp
Normal file
25
ImageProcessor.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
#include "ImageProcessor.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
void ImageProcessor::ProcessImage(uint32_t width, uint32_t height, uint8_t *imgPointer)
|
||||
{
|
||||
Mat frame(height, width, CV_16U, imgPointer, Mat::AUTO_STEP);
|
||||
|
||||
//normalize(frame, scaled, 0, 255, NORM_MINMAX);
|
||||
//scaled.convertTo(scaled, CV_8UC1);
|
||||
|
||||
//applyColorMap(scaled, color, COLORMAP_JET);
|
||||
|
||||
//namedWindow("FLIR", WINDOW_AUTOSIZE);
|
||||
//imshow("FLIR", color);
|
||||
int key = waitKey(1);
|
||||
//if key == 27, then break
|
||||
//release()
|
||||
//destroyAllWindows()
|
||||
}
|
||||
15
ImageProcessor.hpp
Normal file
15
ImageProcessor.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IMAGEPROCESSOR_H
|
||||
#define IMAGEPROCESSOR_H
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
class ImageProcessor
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void ProcessImage(uint32_t width, uint32_t height, uint8_t *imgPointer);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -133,7 +133,7 @@ void StreamManager::CreateStreamBuffers()
|
||||
}
|
||||
}
|
||||
|
||||
void StreamManager::AcquireImages()
|
||||
void StreamManager::AcquireImages(ImageProcessor processor)
|
||||
{
|
||||
if (lDevice == NULL || lStream == NULL)
|
||||
{
|
||||
@@ -198,6 +198,10 @@ void StreamManager::AcquireImages()
|
||||
// Read width, height.
|
||||
lWidth = lImage->GetWidth();
|
||||
lHeight = lImage->GetHeight();
|
||||
|
||||
// Process Image
|
||||
processor.ProcessImage(lWidth, lHeight, lImage->GetDataPointer());
|
||||
|
||||
std::cout << " W: " << std::dec << lWidth << " H: " << lHeight;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <PvStream.h>
|
||||
#include <PvBuffer.h>
|
||||
|
||||
#include "ImageProcessor.hpp"
|
||||
|
||||
#define BUFFER_COUNT (32)
|
||||
typedef std::list<PvBuffer *> BufferList;
|
||||
|
||||
@@ -15,7 +17,7 @@ public:
|
||||
PvResult FindDevice(PvString *aConnectionID);
|
||||
PvResult ConnectToDevice(const PvString &aConnectionID);
|
||||
PvResult OpenStream(const PvString &aConnectionID);
|
||||
void AcquireImages();
|
||||
void AcquireImages(ImageProcessor processor);
|
||||
void Disconnect();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user