• 大小: 33.91MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-27
  • 语言: 其他
  • 标签: Qt  Halcon  迈德威视  

资源简介

Qt+Halcon封装迈德威视相机

资源截图

代码片段和文件信息

#include “capturethread.h“
#include “mainwindow.h“
#include 

#include 
#include “CameraApi.h“

//SDK使用
extern int                  g_hCamera;          //设备句柄
extern unsigned char        * g_pRawBuffer;     //raw数据
extern unsigned char        * g_pRgbBuffer;     //处理后数据缓存区
extern tSdkframeHead        g_tframeHead;       //图像帧头信息
extern tSdkCameraCapbility  g_tCapability;      //设备描述信息


extern Width_Height         g_W_H_INFO;         //显示画板到大小和图像大小
extern BYTE                 *g_readBuf;         //显示数据buffer
extern int                  g_read_fps;         //统计帧率
extern int                  g_SaveImage_type;   //保存图像格式

CaptureThread::CaptureThread(Qobject *parent) :
    QThread(parent)
{
    pause_status = true;
    quit = false;

    for(int i = 0; i < 256; i++)
    {
       grayColourTable.append(qRgb(i i i));
    }
}

void CaptureThread::run()
{
    forever
    {
        if(!pause_status)
        {
if(quit) break;
            if (CameraGetImageBuffer(g_hCamera&g_tframeHead&g_pRawBuffer2000) == CAMERA_STATUS_SUCCESS)
            {
                CameraImageProcess(g_hCamerag_pRawBufferg_pRgbBuffer&g_tframeHead);
CameraReleaseImageBuffer(g_hCamerag_pRawBuffer);

                if(g_tframeHead.uiMediaType==CAMERA_MEDIA_TYPE_MONO8){

                    memcpy(g_readBufg_pRgbBufferg_W_H_INFO.buffer_size);

if(quit) break;
                    QImage img(g_readBuf g_W_H_INFO.sensor_width g_W_H_INFO.sensor_heightQImage::Format_Indexed8);
                    img.setColorTable(grayColourTable);
                    emit captured(img);

                }else{
                    memcpy(g_readBufg_pRgbBufferg_W_H_INFO.buffer_size*3);
if(quit) break;
QImage img = QImage((const uchar*)g_readBuf g_W_H_INFO.sensor_width  g_W_H_INFO.sensor_height QImage::Format_RGB888);
                    //QImage img(g_readBuf g_W_H_INFO.sensor_width g_W_H_INFO.sensor_heightQImage::Format_RGB888);
                    emit captured(img);
                }

                g_read_fps++;//统计抓取帧率

            }else{
                printf(“timeout \n“);
                usleep(1000);
            }
        } else usleep(1000);
        if(quit) break;
    }
}

void CaptureThread::stream()
{
    pause_status = false;
}

void CaptureThread::pause()
{
    pause_status = true;
}

void CaptureThread::stop()
{
    pause_status = false;
    quit = true;
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-24 13:52  QT5\
     目录           0  2018-12-24 13:52  QT5\.vs\
     目录           0  2018-12-24 13:52  QT5\.vs\QT5Demo\
     目录           0  2018-12-24 13:52  QT5\.vs\QT5Demo\v14\
     文件       18944  2018-12-24 13:43  QT5\.vs\QT5Demo\v14\.suo
     文件        2541  2016-06-22 11:16  QT5\capturethread.cpp
     文件         480  2016-06-22 11:17  QT5\capturethread.h
     目录           0  2018-12-24 13:52  QT5\Debug\
     文件      229478  2018-12-24 13:31  QT5\Debug\capturethread.obj
     文件      187991  2018-12-24 13:31  QT5\Debug\main.obj
     文件      738008  2018-12-24 13:31  QT5\Debug\mainwindow.obj
     文件       55945  2018-12-24 13:31  QT5\Debug\moc_capturethread.obj
     文件      201091  2018-12-24 13:31  QT5\Debug\moc_mainwindow.obj
     文件        2411  2018-12-24 13:31  QT5\Debug\QT5Demo.log
     目录           0  2018-12-24 13:52  QT5\Debug\QT5Demo.tlog\
     文件        5912  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\CL.command.1.tlog
     文件      322976  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\CL.read.1.tlog
     文件        2436  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\CL.write.1.tlog
     文件        2420  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\custombuild.command.1.tlog
     文件         538  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\custombuild.read.1.tlog
     文件         754  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\custombuild.write.1.tlog
     文件        2002  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\link.command.1.tlog
     文件        4634  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\link.read.1.tlog
     文件         942  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\link.write.1.tlog
     文件         168  2018-12-24 13:31  QT5\Debug\QT5Demo.tlog\QT5Demo.lastbuildstate
     文件     4165632  2018-12-24 13:31  QT5\Debug\vc140.pdb
     目录           0  2018-12-24 13:52  QT5\GeneratedFiles\
     目录           0  2018-12-24 13:52  QT5\GeneratedFiles\Debug\
     文件        4251  2018-12-24 13:31  QT5\GeneratedFiles\Debug\moc_capturethread.cpp
     文件       15261  2018-12-24 13:31  QT5\GeneratedFiles\Debug\moc_mainwindow.cpp
     文件       41494  2018-12-24 13:31  QT5\GeneratedFiles\ui_mainwindow.h
............此处省略699个文件信息

评论

共有 条评论