Ask Your Question

patrick129's profile - activity

2020-03-13 05:57:32 -0600 commented answer How to compile Opencv 3.4.1 program in VS 2019 with Opencv 4.1.1?

Thank you so much for your advice! I'll try this way and tell you if it works or not.

2020-03-13 05:55:11 -0600 marked best answer How to compile Opencv 3.4.1 program in VS 2019 with Opencv 4.1.1?

I've a program written for Opencv 3.4.1 in order to capture image by basler camera and store it in "IplImage*" type of image then show it in Opencv window. I'm using Visual Studio 2019 with Opencv 4.1.1 and when i compiled it it had some errors:

At "static IplImage* s_pCvSrcImg = NULL;" : Missing type specifier-assumed int.Note: C++ does not support the default -int

memcpy(s_pCvSrcImg->imageData, ptrGrabResult->GetBuffer(), ptrGrabResult->GetImageSize());: Identifier " memcpy" cannot be found

And the same errors for cvCanny ,cvShowImage, cvWaitKey in the below Lines Here is the program:

#define OPENCV
#if defined OPENCV
#include "opencv2/opencv.hpp"
#endif  //#if defined OPENCV
#include <conio.h>
// Include files to use the PYLON API.
#include <pylon/PylonIncludes.h>
#ifdef PYLON_WIN_BUILD
#    include <pylon/PylonGUI.h>
#endif

// Namespace for using pylon objects.
using namespace Pylon;

// Namespace for using cout.
using namespace std;

// Namespace for using GenApi objects.
using namespace GenApi;

// Number of images to be grabbed.
static const uint32_t c_countOfImagesToGrab = 1;

#if defined OPENCV
static char s_szCvWindowNameSrc[64] = "Source";
static char s_szCvWindowNameProc[64] = "Processed";
static IplImage* s_pCvSrcImg = NULL;    //Source image
static IplImage* s_pCvProcImg = NULL;   // Destination image
#endif  //#if defined OPENCV

 int main(int argc, char* argv[])
{
// The exit code of the sample application.
int exitCode = 0;

// Before using any pylon methods, the pylon runtime must be initialized. 
PylonInitialize();

try
{

// Create an instant camera object with the camera device found first.
    CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());
   // Print the model name of the camera.
    cout << "Using device " << camera.GetDeviceInfo().GetModelName() << endl;

    // The parameter MaxNumBuffer can be used to control the count of buffers
    // allocated for grabbing. The default value of this parameter is 10.
    camera.MaxNumBuffer = 5;

    // Start the grabbing of c_countOfImagesToGrab images.
    // The camera device is parameterized with a default configuration which
    // sets up free-running continuous acquisition.
    // camera.StartGrabbing( c_countOfImagesToGrab);
    camera.StartGrabbing(-1);

#if defined OPENCV
    INodeMap& nodemap = camera.GetNodeMap();

    CIntegerPtr width(nodemap.GetNode("Width"));
    unsigned int uiWidth = (unsigned int)width->GetValue();

    CIntegerPtr height(nodemap.GetNode("Height"));
    unsigned int uiHeight = (unsigned int)height->GetValue();

    // Create OpenCV window for mono8
    s_pCvSrcImg = cvCreateImage(cvSize(uiWidth, uiHeight), IPL_DEPTH_8U, 1);
    s_pCvProcImg = cvCreateImage(cvSize(uiWidth, uiHeight), IPL_DEPTH_8U, 1);

    // for change fps automatically 
    CBooleanPtr AcquisitionFrameRateEnable(nodemap.GetNode("AcquisitionFrameRateEnable"));
    AcquisitionFrameRateEnable->SetValue(true);

 #endif //#if defined OPENCV

    // This smart pointer will receive the grab result data.
    CGrabResultPtr ptrGrabResult;

    // Camera.StopGrabbing() is called automatically by the RetrieveResult() method
    // when c_countOfImagesToGrab images have been retrieved.
    int iCount = 0;
    bool bQuit = false;

    while ( false == bQuit )
    {
        // Wait for an image and then retrieve it. A timeout of 5000 ms is used.
        camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException);

        //cout << iCount << ", " << endl;
        // Image grabbed successfully?
        if (ptrGrabResult->GrabSucceeded())
        {
#if defined OPENCV
    DWORD dwTimeStart = GetTickCount();

  memcpy(s_pCvSrcImg->imageData, ptrGrabResult->GetBuffer(), ptrGrabResult->GetImageSize());// Retleave image 
  from SDK
  cvCanny(s_pCvSrcImg, s_pCvProcImg, 64, 128);  // Edge detection
  cvShowImage(s_szCvWindowNameSrc, s_pCvSrcImg);    // Show camera image
  cvShowImage(s_szCvWindowNameProc, s_pCvProcImg); // Show processed image
  cvWaitKey(50);    // To keep show cvShowImage

  DWORD dwProcTime = GetTickCount() - dwTimeStart;
  //cout << "Process Time = " << dwProcTime<< "[ms] img" << ptrGrabResult->GetBlockID() << endl;
     printf("\rProcess Time = %ld[ms] img %ld", dwProcTime, (DWORD)ptrGrabResult->GetBlockID ...
(more)
2020-03-13 05:55:11 -0600 received badge  Scholar (source)
2020-03-12 11:59:27 -0600 asked a question How to compile Opencv 3.4.1 program in VS 2019 with Opencv 4.1.1?

How to compile Opencv 3.4.1 program in VS 2019 with Opencv 4.1.1? I've a program written for Opencv 3.4.1 in order to ca

2019-11-13 22:01:41 -0600 asked a question Change camera resolution in C++?

Change camera resolution in C++? I've using 2 3.0 Usb basler cameras and when i runed the program to capture cameras' vi

2019-11-13 20:59:57 -0600 asked a question Change camera resolution?

Change camera resolution? I can't use command 'import cv2' and ' using namespace cv2' because i don't have 'cv2' module

2019-11-08 02:25:51 -0600 commented question My 2 camera's video capture program didn't work

@urres_coding I'll do this to see if what will be different

2019-11-07 11:17:39 -0600 asked a question My 2 camera's video capture program didn't work

My 2 camera's video capture program didn't work I have used exactly the program suggested in my previous question and th

2019-10-25 03:22:49 -0600 commented question How to rotate image in my camera's video?

@berak I'll try with this program and do as you say. I appreciate it so much. Lots of thanks!! Actually I think dont ne

2019-10-25 03:22:27 -0600 commented question How to rotate image in my camera's video?

@berak I'll try with this program and do as you say. I appreciate it so much. Lots of thanks!! Actually I think dont ne

2019-10-25 03:17:38 -0600 commented question How to rotate image in my camera's video?

@Kitnos Thank you I've solved this problem with much easier code. Yes i'm new to the opencv and very stupid to realize t

2019-10-25 03:15:19 -0600 commented question How to rotate image in my camera's video?

@berak I did this with the help of a forum and ye i didn't understand the code and copied it and saw that error.

2019-10-25 03:11:21 -0600 received badge  Enthusiast
2019-10-24 22:49:28 -0600 edited question How to rotate image in my camera's video?

How to rotate image in my camera's video? I want to capture video frm my camera and rotate it at the same times and i've

2019-10-24 21:35:19 -0600 asked a question How to rotate image in my camera's video?

How to rotate image in my camera's video? My camera video has its frame upside down. How can i rotate all frame of my vi

2019-10-15 04:19:18 -0600 asked a question video capture for 2 cameras

video capture for 2 cameras Hi i have a question today: I have 2 cameras and want to use the second to capture video.I u

2019-10-15 04:19:11 -0600 asked a question video capture for 2 cameras

video capture for 2 cameras Hi i have a question today: I have 2 cameras and want to use the second to capture video.I u

2019-10-09 03:24:13 -0600 commented answer Error C2015

@berak THANK YOU SO MUCH I've fixed this

2019-10-09 03:19:05 -0600 asked a question Error C2015

Error C2015 Hi I have a question again: I'm writing program for capturing video from my camera in Opencv and this is the

2019-10-02 04:35:49 -0600 commented question capture video from camera by OpenCV?

@berak You mean that i have to install gstreamer into my openCV library ?

2019-10-02 04:34:59 -0600 commented question capture video from camera by OpenCV?

@berak Yes My camera works very well.

2019-10-02 04:09:55 -0600 commented question capture video from camera by OpenCV?

@berak no problem thank you

2019-10-02 04:06:18 -0600 edited question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co

2019-10-02 04:06:15 -0600 edited question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co

2019-10-02 04:05:45 -0600 edited question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co

2019-10-02 04:05:39 -0600 edited question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co

2019-10-02 04:03:09 -0600 commented question capture video from camera by OpenCV?

@berak Is this ok?

2019-10-02 04:02:34 -0600 edited question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co

2019-10-02 03:20:42 -0600 edited question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co

2019-10-02 03:19:24 -0600 edited question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co

2019-10-02 03:18:49 -0600 received badge  Editor (source)
2019-10-02 03:18:49 -0600 edited question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co

2019-10-02 03:16:47 -0600 commented question capture video from camera by OpenCV?

@berak I'll edit the screenshot thanks

2019-10-02 03:11:28 -0600 asked a question capture video from camera by OpenCV?

capture video from camera by OpenCV? I've written code for video capturing from my Basler camera but when compile the co