Ask Your Question

NerdyDroneBuilder's profile - activity

2017-08-09 14:31:22 -0600 answered a question How to get pixel's value from a picture?

Everyone posts code, none of it was really helpful. Here's how you can do it:

Also posted here on PasteBin: https://pastebin.com/tA1R8Qtm

// -----------------------------------------------------
// ---------- FIND AVG LUMINENCE OF FRAME --------------
// -----------------------------------------------------

// Assuming you have a cv::Mat to start with called "input_mat"
cv::Mat grayMat; 
cv::cvtColor(input_mat, grayMat, CV_BGR2GRAY);

int Totalintensity = 0;
for (int i=0; i < grayMat.rows; ++i){
    for (int j=0; j < grayMat.cols; ++j){
        Totalintensity += (int)grayMat.at<uchar>(i, j);
    }
}

// Find avg lum of frame
float avgLum = 0;
avgLum = Totalintensity/(grayMat.rows * grayMat.cols);
2017-07-25 12:36:11 -0600 received badge  Editor (source)
2017-07-25 12:35:40 -0600 answered a question Allied Vision VIMBA and OpenCV

Hi all: I spent a lot of time trying to find the best way to get Vimba and OpenCV to play together - here's what I have.

Crux of the issue:

FramePtr pFrame;
VmbUchar_t *pImage = Null;
VmbUint32_t timeout = 500;
VmbUint43_t nWidth = 0;
VmbUint43_t nHeight = 0;

if (VmbErrorSuccess == cameras[ 0 ]->Camera::AcquireSingleImage( pFrame, timeout ) ) {

if (VmbErrorSuccess != pFrame->getWidth( nWidth ); std::cout << "FAILED to aquire width of frame!" << std::endl;

if (VmbErrorSuccess != pFrame->getWidth( nHeight ); std::cout << "FAILED to aquire height of frame!" << std::endl;

if (VmbErrorSuccess != pFrame->getImage( pImage ); std::cout << "FAILED to acquire image data of frame!" << std::endl;

cv::Mat cvMat = cv::Mat(nHeight, nWidth, CV_8UC1, pImage ); cv::cvtColor(cvMat, cvMat, CV_BayerBG2RGB); // My camera is set up to publish BayerBG. It's an efficient codec.

cv::imshow("Our Great Window", cvMat); cv::waitKey(1); }

Also below is more of my program (~250 lines) if you want to see how I also find my cameras, open them, and store that information. https://pastebin.com/z7i6dRbn

Good luck.

Good luck to all of you!