[myimage] must be explicitely created with width and height
This commit is contained in:
parent
6ef19c2375
commit
f4231e281b
19
myimage.cpp
19
myimage.cpp
@ -1,20 +1,28 @@
|
|||||||
#include "myimage.h"
|
#include "myimage.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include "mylogger.h"
|
||||||
|
|
||||||
MyImage::MyImage()
|
MyImage::MyImage(uint32_t width, uint32_t height): img_width(width), img_height(height)
|
||||||
{}
|
{
|
||||||
|
buffer = new char[width * height];
|
||||||
|
}
|
||||||
|
|
||||||
MyImage::MyImage(Pylon::CGrabResultPtr ptr) {
|
MyImage::MyImage(Pylon::CGrabResultPtr ptr) {
|
||||||
setFrame(ptr);
|
setFrame(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MyImage::~MyImage() {
|
||||||
|
delete[] buffer;
|
||||||
|
}
|
||||||
|
|
||||||
bool MyImage::setFrame(Pylon::CGrabResultPtr ptr) {
|
bool MyImage::setFrame(Pylon::CGrabResultPtr ptr) {
|
||||||
|
qDebug() << "Setting frame from pointer";
|
||||||
bool valid = ptr.IsValid() && ptr->GetWidth() <= max_width && ptr->GetHeight() <= max_height;
|
bool valid = ptr.IsValid() && ptr->GetWidth() <= max_width && ptr->GetHeight() <= max_height;
|
||||||
if (valid) {
|
if (valid) {
|
||||||
img_index = ptr->GetID();
|
img_index = ptr->GetID();
|
||||||
img_width = ptr->GetWidth();
|
img_width = ptr->GetWidth();
|
||||||
img_height = ptr->GetHeight();
|
img_height = ptr->GetHeight();
|
||||||
memcpy(&buffer, ptr->GetBuffer(), ptr->GetImageSize());
|
memcpy(buffer, ptr->GetBuffer(), ptr->GetImageSize());
|
||||||
auto t = std::chrono::system_clock::now();
|
auto t = std::chrono::system_clock::now();
|
||||||
img_timestamp = std::chrono::system_clock::to_time_t(t);
|
img_timestamp = std::chrono::system_clock::to_time_t(t);
|
||||||
}
|
}
|
||||||
@ -22,11 +30,12 @@ bool MyImage::setFrame(Pylon::CGrabResultPtr ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MyImage::setFrame( Pylon::CPylonImage &img) {
|
bool MyImage::setFrame( Pylon::CPylonImage &img) {
|
||||||
|
qDebug() << "Setting frame from Pylon image (" << img.GetWidth() << "x" << img.GetHeight() << ")";
|
||||||
bool valid = img.IsValid() && img.GetWidth() <= max_width && img.GetHeight() <= max_height;
|
bool valid = img.IsValid() && img.GetWidth() <= max_width && img.GetHeight() <= max_height;
|
||||||
if (valid) {
|
if (valid) {
|
||||||
img_width = img.GetWidth();
|
img_width = img.GetWidth();
|
||||||
img_height = img.GetHeight();
|
img_height = img.GetHeight();
|
||||||
memcpy(&buffer, img.GetBuffer(), img.GetImageSize());
|
memcpy(buffer, img.GetBuffer(), img.GetImageSize());
|
||||||
auto t = std::chrono::system_clock::now();
|
auto t = std::chrono::system_clock::now();
|
||||||
img_timestamp = std::chrono::system_clock::to_time_t(t);
|
img_timestamp = std::chrono::system_clock::to_time_t(t);
|
||||||
}
|
}
|
||||||
@ -50,7 +59,7 @@ int64_t MyImage::index() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *MyImage::data() {
|
void *MyImage::data() {
|
||||||
return &buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t MyImage::timestamp() {
|
time_t MyImage::timestamp() {
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
class MyImage
|
class MyImage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyImage();
|
MyImage(uint32_t width, uint32_t height);
|
||||||
MyImage(Pylon::CGrabResultPtr ptr);
|
MyImage(Pylon::CGrabResultPtr ptr);
|
||||||
|
~MyImage();
|
||||||
|
|
||||||
int width();
|
int width();
|
||||||
int height();
|
int height();
|
||||||
@ -23,9 +24,9 @@ private:
|
|||||||
uint32_t img_height = 0;
|
uint32_t img_height = 0;
|
||||||
int64_t img_index = 0;
|
int64_t img_index = 0;
|
||||||
time_t img_timestamp;
|
time_t img_timestamp;
|
||||||
static const int max_width = 4096;
|
static const int max_width = 5184;
|
||||||
static const int max_height = 1536;
|
static const int max_height = 2048;
|
||||||
char buffer[max_width * max_height];
|
char *buffer; //[max_width * max_height];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MYIMAGE_H
|
#endif // MYIMAGE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user