2

我正在使用 35MM EO 百万像素固定 FL 镜头 Edmund Optics 相机、OpenCV 2.4.6 和 Ubuntu 12.04 LTS 作为我的开发环境。我也在使用 C 来开发,而不是 C++。相机有一个我正在关注的 API,我相信我已经正确设置了所有内容。我初始化相机,设置内存位置,并冻结视频。然后我使用 OpenCV 从内存中获取图像,但我的图像与应有的不同(可能如下所示)。我的图像数据是否从垃圾内存位置提取数据?如何访问“is_FreezeVideo”保存的图像以供 OpenCV 完成图像处理?打印出来的图像可以在这里看到http://i.imgur.com/kW6aqB3.png

我正在使用的代码如下。

#include "../Include/Camera.h"
#include <wchar.h>
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
//#include <opencv2/opencv.hpp>
#include <ueye.h>

// uEye variables
HIDS m_hCam;                                    // handle to room
HWND m_hWndDisplay;                             // handle to diplay window
int m_Ret;                                      // return value of uEye  SDK functions
int m_nColorMode = 0;                               // Y8/RGB16/RGB24/REG32
int m_nBitsPerPixel=8;                          // number of bits needed store one pixel
int m_nSizeX = 1280;                             // width of video
int m_nSizeY = 1024;                             // height of video
int m_lMemoryId;                                // grabber memory - buffer   ID
char* m_pcImageMemory;                          // grabber memory - pointer to buffer
int m_nRenderMode = IS_RENDER_FIT_TO_WINDOW;    //render  mode

void getAzimuth(){

}
void getElevation(){

}
void initializeCamera(){

    if (m_hCam !=0 ) {
        //free old image mem.
        is_FreeImageMem (m_hCam, m_pcImageMemory, m_lMemoryId);
        is_ExitCamera (m_hCam);
    }

    // init room
    m_hCam = (HIDS) 0;    // open next room
    m_Ret = is_InitCamera (&m_hCam, NULL);    // init room

    if (m_Ret == IS_SUCCESS) {
        // retrieve original image size
        SENSORINFO sInfo;
        is_GetSensorInfo (m_hCam, &sInfo);
        m_nSizeX = sInfo.nMaxWidth;
        m_nSizeY = sInfo.nMaxHeight;

        printf("Width: %d Height: ", m_nSizeX, m_nSizeY);

        // setup the color depth to the current windows setting
        is_GetColorDepth (m_hCam, &m_nBitsPerPixel, &m_nColorMode);
        is_SetColorMode (m_hCam, m_nColorMode);

        //printf ("m_nBitsPerPixel=%i  m_nColorMode=%i \n", m_nBitsPerPixel, IS_CM_BAYER_RG8);

        // memory initialization
        is_AllocImageMem (m_hCam, m_nSizeX, m_nSizeY, m_nBitsPerPixel, &m_pcImageMemory, &m_lMemoryId);
        //set memory active
        is_SetImageMem (m_hCam, m_pcImageMemory, m_lMemoryId);
        // display initialization
        is_SetImageSize (m_hCam, m_nSizeX, m_nSizeY);
        is_SetImagePos(m_hCam, 0, 0);
        is_SetDisplayMode (m_hCam, IS_SET_DM_DIB);
    } else {
        printf("No Camera Initialized! %c", 10);

    }
if (m_hCam !=0) {
    INT dummy;
    char *pMem, *pLast;
    double fps = 0.0;

    if (is_FreezeVideo (m_hCam, IS_WAIT) == IS_SUCCESS) {
        m_Ret = is_GetActiveImageMem(m_hCam, &pLast, &dummy);
        m_Ret = is_GetImageMem(m_hCam, (void**)&pLast);

    }

    IplImage* tmpImg = cvCreateImageHeader (cvSize (m_nSizeX, m_nSizeY), IPL_DEPTH_8U, 1);
    tmpImg->imageData = &m_pcImageMemory;

    cvNamedWindow("src",1);
    cvShowImage("src",tmpImg);

    cvWaitKey(0);

}

}

谢谢

4

2 回答 2

0

您需要使用 is_ImageFile 函数将图像文件保存为文件名。您可以从 is_ImageFile 函数中查看示例示例。您可以将其保存为您需要的格式(bmp,png,jpeg)。

问候, 斯里尼瓦斯

于 2013-10-16T08:55:04.117 回答
0

问题是相机属性。设置好亮度等属性后,我们现在得到一张实际的图像

于 2013-10-17T19:34:21.357 回答