Add Simple Image Processor

This commit is contained in:
Grant Terris
2019-08-10 18:21:38 -07:00
parent 99b5733710
commit 7155fce24f
7 changed files with 59 additions and 9 deletions

View File

@@ -4,7 +4,8 @@
"name": "Linux", "name": "Linux",
"includePath": [ "includePath": [
"${workspaceFolder}/**", "${workspaceFolder}/**",
"/opt/pleora/ebus_sdk/Ubuntu-x86_64/include/**" "/opt/pleora/ebus_sdk/Ubuntu-x86_64/include/**",
"/usr/local/include/opencv4/**"
], ],
"defines": [], "defines": [],
"compilerPath": "/usr/bin/gcc", "compilerPath": "/usr/bin/gcc",

View File

@@ -14,6 +14,7 @@ include_directories(
add_executable( FaultFinder add_executable( FaultFinder
FaultFinder.cpp FaultFinder.cpp
StreamManager.cpp StreamManager.cpp
ImageProcessor.cpp
) )
target_link_libraries( FaultFinder target_link_libraries( FaultFinder

View File

@@ -1,30 +1,32 @@
#include <iostream> #include <iostream>
#include "StreamManager.hpp" #include "StreamManager.hpp"
#include "ImageProcessor.hpp"
using namespace std; using namespace std;
int main() int main()
{ {
StreamManager mgr; ImageProcessor processor;
StreamManager manager;
PvString lConnectionID; PvString lConnectionID;
// If no devies are found, exit. // If no devies are found, exit.
if (mgr.FindDevice(&lConnectionID).IsFailure()) if (manager.FindDevice(&lConnectionID).IsFailure())
{ {
return -1; return -1;
} }
if (mgr.ConnectToDevice(lConnectionID).IsFailure()) if (manager.ConnectToDevice(lConnectionID).IsFailure())
{ {
return -1; return -1;
} }
mgr.OpenStream(lConnectionID); manager.OpenStream(lConnectionID);
mgr.AcquireImages(); manager.AcquireImages(processor);
mgr.Disconnect(); manager.Disconnect();
return 0; return 0;
} }

25
ImageProcessor.cpp Normal file
View 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
View 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

View File

@@ -133,7 +133,7 @@ void StreamManager::CreateStreamBuffers()
} }
} }
void StreamManager::AcquireImages() void StreamManager::AcquireImages(ImageProcessor processor)
{ {
if (lDevice == NULL || lStream == NULL) if (lDevice == NULL || lStream == NULL)
{ {
@@ -198,6 +198,10 @@ void StreamManager::AcquireImages()
// Read width, height. // Read width, height.
lWidth = lImage->GetWidth(); lWidth = lImage->GetWidth();
lHeight = lImage->GetHeight(); lHeight = lImage->GetHeight();
// Process Image
processor.ProcessImage(lWidth, lHeight, lImage->GetDataPointer());
std::cout << " W: " << std::dec << lWidth << " H: " << lHeight; std::cout << " W: " << std::dec << lWidth << " H: " << lHeight;
} }
else else

View File

@@ -4,6 +4,8 @@
#include <PvStream.h> #include <PvStream.h>
#include <PvBuffer.h> #include <PvBuffer.h>
#include "ImageProcessor.hpp"
#define BUFFER_COUNT (32) #define BUFFER_COUNT (32)
typedef std::list<PvBuffer *> BufferList; typedef std::list<PvBuffer *> BufferList;
@@ -15,7 +17,7 @@ public:
PvResult FindDevice(PvString *aConnectionID); PvResult FindDevice(PvString *aConnectionID);
PvResult ConnectToDevice(const PvString &aConnectionID); PvResult ConnectToDevice(const PvString &aConnectionID);
PvResult OpenStream(const PvString &aConnectionID); PvResult OpenStream(const PvString &aConnectionID);
void AcquireImages(); void AcquireImages(ImageProcessor processor);
void Disconnect(); void Disconnect();
private: private: