📄 imageobjectdlg.h
字号:
// ImageObjectDlg.h : header file
//
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
#include "staticimage.h"
#include "childfrm.h"
typedef struct tagDetectRegion
{
CRect region;
int threshold;
}DetectRegion;
typedef struct tagSystemSetParameter
{
int detect_num;
int image_light;
int image_contrast;
DetectRegion dtr[6];
}SystemSetParameter;
#define UM_PROCESS_IMAGE_DATA WM_USER+876
#define IMAGE_HEIGHT 576
#define IMAGE_WIDTH 720
#define MAX_DETECT_REGION_NUM 4
#define MAX_REGION_WIDTH 200
#define MAX_REGION_HEIGHT 80
#define NO_OBJECT 10
#define OBJECT_HEAD 20
#define OBJECT_MIDDLE 30
#define OBJECT_TAIL 40
#define BRIGHT_CURVE_SPEED 5
#define GET_IMAGE_EVENT 345
// CImageObjectDlg dialog
class CImageObjectDlg : public CDialog
{
// Construction
public:
CImageObjectDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_IMAGEOBJECT_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
// 图像亮度设定滑块
CSliderCtrl m_ImageLightSlider;
// 图像对比度设定滑块
CSliderCtrl m_ImageContrastSlider;
CRichEditCtrl m_SetDetectNum;
CComboBox m_SelectDetectRegion;
CRichEditCtrl m_SetDetectRegionHeight;
CRichEditCtrl m_SetDetectRegionWidth;
CRichEditCtrl m_SetDetectThreshold;
// 1号检测区平均亮度
CRichEditCtrl m_DetectRegion1Light;
CRichEditCtrl m_DetectRegion2Light;
CRichEditCtrl m_DetectRegion3Light;
CRichEditCtrl m_DetectRegion4Light;
CRichEditCtrl m_DetectRegion5Light;
CRichEditCtrl m_DetectRegion6Light;
CRichEditCtrl m_DetectRegion1Threshold;
CRichEditCtrl m_DetectRegion2Threshold;
CRichEditCtrl m_DetectRegion3Threshold;
CRichEditCtrl m_DetectRegion4Threshold;
CRichEditCtrl m_DetectRegion5Threshold;
CRichEditCtrl m_DetectRegion6Threshold;
CRichEditCtrl m_Counter;
CButton m_bntSetDetect;
CStatic m_ShowImage;
CStatic m_CurveWindow;
CChildFrame *m_lpShowVideoWnd;
SystemSetParameter m_SysSetPara;
CBitmap m_bmpCurve;
CBitmap m_bmpMain;
CPalette m_Palette;
BITMAPINFO *m_lpbmiVideo;
BITMAPINFO *m_lpbmiCurve;
BYTE * m_bufferVideo; //主显示口的DIB位图数据区指针
BYTE m_bufferCurveBlock[100*256]; //块曲线图的DIB位图数据区指针
BYTE m_bufferCurveHist[100*256]; //流曲线图的DIB位图数据区指针
void * lpcallbakdata;
UINT_PTR m_GetImageTimer;
bool m_SetEnable;
long m_lBrightMin;
long m_lBrightMax;
long m_lBrightStep;
long m_lContrastMin;
long m_lContrastMax;
long m_lContrastStep;
//图像检测相关变量
int m_CardID;
long m_iDetectCountTotal; //检测到的目标总计数;
int m_iDetectCountTemp; //交换数据暂存
int m_iCurrentDetectRegionID;//当前检测区ID
int m_CurveSpeed; //平均亮度曲线移动速度
int m_indexofLightHist; //平均亮度历史数据存储区的当前位置指示
bool m_RegionPosiAdjust; //检测区域正在调整位置状态标记
int m_CurveAverage[MAX_DETECT_REGION_NUM];//亮度累计变量
int m_iRegionDetectStatu[MAX_DETECT_REGION_NUM];//每个检测区的检测状态 标记变量
CRect DetectRegion[MAX_DETECT_REGION_NUM];//检测区域对应的客户区矩形
BYTE m_RegionLightHist[MAX_DETECT_REGION_NUM][100];//指针数组,每个检测区的平均亮度历史数据存储区指针
BYTE m_BrightnessAverage[MAX_DETECT_REGION_NUM];//每个检测区的平均亮度
BYTE m_VAverageLight[MAX_DETECT_REGION_NUM][MAX_REGION_WIDTH]; //每个检测区域的垂直平均结果存储区指针
BYTE m_regionImageData[MAX_REGION_WIDTH*MAX_REGION_HEIGHT]; //data take from image;
CPoint m_StartPoint; //配置模式下,移动检测区域的起始位置
CPoint m_LasterPoint;
bool GetParameter();
bool InitVideoCaptureCard();
bool SetParameter();
bool SaveParameter();
void RectImageToDlg(CRect *lpSource,CRect *lpResult);
void RectDlgToImage(CRect *lpSource,CRect *lpResult);
void GetRegionImageData();
void RegionImageProcess(int region_id);
void DisplayResult();
bool CheckHeader(BYTE *processData,long size,int threshold);
bool CheckEnd(BYTE *processData,long size,int threshold);
int CheckBody(BYTE *processData,long size,int threshold);
int CheckUpEdge(BYTE *processData,long size,int threshold);
int CheckDownEdge(BYTE *processData,long size,int threshold);
void BinTranslate(BYTE *processData,BYTE *result,long size,int threshold);
void AverageFilter1D(BYTE *processData,long size,int windowSize);
void MiddleFilter1D(BYTE *processData,long size,int windowSize);
public:
afx_msg void OnBnClickedBtnSet();
afx_msg void OnEnChangeRe2Detect6Threshold();
afx_msg void OnEnChangeRe2RegionCountSet();
afx_msg void OnEnKillfocusRe2RegionCountSet();
afx_msg void OnCbnSelchangeComboSelectRegion();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnCancel();
afx_msg LRESULT ImageProcess( WPARAM wParam, LPARAM lParam);
public:
afx_msg void OnEnKillfocusRe2RegionHeight();
public:
afx_msg void OnEnKillfocusRe2RegionWidth();
public:
afx_msg void OnEnKillfocusRe2RegionThreshold();
public:
afx_msg void OnTimer(UINT_PTR nIDEvent);
public:
afx_msg void OnBnClickedButtonDebug();
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -