#include "L2DataCapture.h"
|
#include "CaptureUtil.h"
|
#include "THSActionUtil.h"
|
#include "Win32Util.h"
|
#include "LimitUpCapture.h"
|
#include "IndustryCapture.h"
|
void gray();
|
void ths();
|
/*
|
#include <amp.h>
|
#include <amp_math.h>
|
*/
|
|
DWORD WINAPI threadname(LPVOID lpParamter) // 函数名字可随意
|
{
|
int* index = (int*)lpParamter;
|
|
int p = *index;
|
|
L2DataCapture* creenDataCapture = new L2DataCapture();
|
while (true)
|
{
|
//同花顺(v9.10.50) - 深圳Level-2分时走势
|
//同花顺(v9.10.50) - pppp
|
list<TradeData> map = creenDataCapture->captureLevel2TradeData(cv::imread("C:\\Users\\Administrator\\Desktop\\ocr\\demo\\0_388.jpg"), p);
|
//break;
|
}
|
|
return 0L;
|
}
|
|
DWORD WINAPI inputCode(LPVOID lpParamter) // 函数名字可随意
|
{
|
Sleep(1000);
|
char code[] = "601012";
|
for (int i = 0;i < 6;i++)
|
{
|
keybd_event(code[i], 0, 0, 0);
|
keybd_event(code[i], 0, KEYEVENTF_KEYUP, 0);
|
}
|
return 0L;
|
}
|
|
|
DWORD WINAPI inputEnter(LPVOID lpParamter) // 函数名字可随意
|
{
|
Sleep(1500);
|
keybd_event(VK_RETURN, 0, 0, 0);
|
keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
|
HWND win = FindWindowA(0, "添加股票");
|
|
//CloseWindow(win);
|
Sleep(100);
|
SendMessage(win, WM_CLOSE, 0, 0);
|
return 0L;
|
}
|
|
|
/*
|
int main() {
|
//获取加速设备
|
std::vector<concurrency::accelerator> aors= concurrency::accelerator::get_all();
|
|
int size = 5;
|
int aCPP[] = { 1, 2, 3, 4, 5 };
|
int bCPP[] = { 6, 7, 8, 9, 10 };
|
int sumCPP[5];
|
concurrency::array_view<const int, 1> a(size, aCPP);
|
concurrency::array_view<const int, 1> b(size, bCPP);
|
concurrency::array_view<int, 1> sum(size, sumCPP);
|
*/
|
|
/*
|
concurrency::parallel_for_each(
|
sum.extent,
|
[=](concurrency::index<1> idx) restrict(amp)
|
{
|
sum[idx] = a[idx] + b[idx];
|
}
|
);
|
|
for (int i = 0; i < size; i++)
|
{
|
std::cout << sum[i] << "\n";
|
}
|
*/
|
/*
|
cv::waitKey(0);
|
cv::destroyAllWindows();
|
|
|
return 0;
|
}
|
*/
|
|
void notify(int index, string code, list<TradeData> data, void* context) {
|
cout << index << endl;
|
}
|
void callback(list<LimitUpData> codeList, void* contex) {
|
|
}
|
|
#include "TradeQueueCapture.h"
|
void splitTradeQueue() {
|
//横向切割
|
TradeQueueCapture* tradeQueueCapture = new TradeQueueCapture();
|
for (int i = 0;i < 8;i++)
|
{
|
string path = "C:\\Users\\Administrator\\Desktop\\ocr\\trade_queue\\";
|
path.append(to_string(i)).append(".jpg");
|
|
tradeQueueCapture->recognition(cv::imread(path, cv::IMREAD_GRAYSCALE));
|
|
}
|
|
|
}
|
|
|
int main() {
|
cout << "开始程序" << endl;
|
|
//SetDlgItemText(HWND(0x0002269E), 0x0000040A, TEXT("100"));
|
//SetWindowText(GetDlgItem(HWND(0x0002269E), 0x0000040A),TEXT("100"));
|
//Win32Util::focus(GetDlgItem(HWND(0x0002269E), 0x00000408));
|
//Win32Util::keyboardNum("000333", 10);
|
|
cv::Mat img = CaptureUtil::capture(HWND(0x00020E12));
|
cv::Mat grayImg = ImgUtil::grayImage(img);
|
string path = "C:\\Users\\Administrator\\Desktop\\ocr\\";
|
path.append("order.jpg");
|
cv::imwrite(path, grayImg);
|
return 0;
|
|
ImgUtil::init();
|
|
cout << "ImgUtil初始化完成" << endl;
|
|
IndustryCapture* industryCapture = new IndustryCapture();
|
cout << "LimitUpCapture实例化" << endl;
|
industryCapture->init();
|
cout << "LimitUpCapture初始化完成" << endl;
|
|
industryCapture->captureIndustryCodes();
|
|
|
delete industryCapture;
|
//splitTradeQueue();
|
|
//SendMessage(HWND(0x000B1A86), WM_LBUTTONDOWN, 0, MAKEWORD(1, 1));
|
//SendMessage(HWND(0x000B1A86), WM_LBUTTONUP, 0, MAKEWORD(1, 1));
|
|
|
/*
|
ImgUtil::init();
|
|
ScreenDataCapture* capture = new ScreenDataCapture();
|
capture->init(notify,nullptr);
|
capture->start();
|
capture->startAll();
|
*/
|
|
|
/*
|
RecognitionUtil::init();
|
CaptureUtil::init("同花顺(v9.10.50) - 热门股888");// 热门股888
|
ImgUtil::init();
|
std::list<string> codeList;
|
codeList.push_back("000333");
|
bool setResult = THSActionUtil::setListenL2GP(4,"000333");
|
printf("设置股票代码结果:%d\n", setResult);
|
cv::waitKey(0);
|
cv::destroyAllWindows();
|
return 0;
|
|
*/
|
|
/*
|
RecognitionManager* recognitionManager = new RecognitionManager();
|
|
for (int i = 1;i < 14;i++)
|
{
|
string path = "C:\\Users\\Administrator\\Desktop\\ocr\\split\\";
|
path.append(to_string(i)).append("_1.jpg");
|
list<cv::Mat> list1 = ImgUtil::splitNum(cv::imread(path.c_str(), cv::IMREAD_GRAYSCALE));
|
list<uchar> resultList= recognitionManager->recognitionGPCode(list1);
|
list<uchar>::iterator ele;
|
for (ele = resultList.begin();ele != resultList.end();++ele) {
|
printf("%d",*ele);
|
}
|
printf("\n");
|
}
|
*/
|
|
/*
|
|
RecognitionUtil::init();
|
ImgUtil::init();
|
for (int i = 0;i < 1;i++)
|
{
|
int* params =(int*) malloc(sizeof(int));
|
*params = i;
|
HANDLE hThread = CreateThread(NULL, 0, threadname, params, 0, NULL);
|
}
|
|
|
system("PAUSE");
|
*/
|
//system("PAUSE");
|
//cv::waitKey(0);
|
//cv::destroyAllWindows();
|
|
return 0;
|
}
|
|
int main__() {
|
|
for (int i = 5;i < 6;i++)
|
{
|
cv::Mat img = CaptureUtil::capture(1,CAPTURE_TYPE_L2);
|
string path = "C:\\Users\\Administrator\\Desktop\\ocr\\demo\\";
|
path.append(to_string(i));
|
path.append(".jpg");
|
cv::imwrite(path, img);
|
}
|
|
|
return 1;
|
}
|
|
int main_() {
|
cv::Mat img = ImgUtil::grayImage(cv::imread("E:\\temp\\506518.jpg"));
|
|
imwrite("E:\\temp\\506518_gray.jpg", img);
|
|
clock_t time_2 = clock();
|
LogUtil::debug("灰度完成");
|
//图像分割
|
list<int*> data;
|
try {
|
data = ImgUtil::divideImg(img, 1);
|
if (data.size() == 0) {
|
throw ERROR_CODE_DIVIDE_IMG_FAIL;
|
}
|
}
|
catch (...) {
|
throw ERROR_CODE_DIVIDE_IMG_FAIL;
|
}
|
|
cv::waitKey(0);
|
cv::destroyAllWindows();
|
return 0;
|
}
|
|
void gray() {
|
cv::Mat mat = cv::imread("C:\\Users\\Administrator\\Desktop\\ocr\\new.jpg");
|
uchar* data = mat.data;
|
int rows = mat.rows;
|
int cols = mat.cols;
|
uchar* grayData = (uchar*)malloc(sizeof(uchar) * mat.rows * mat.cols);
|
|
for (int r = 0;r < rows;r++) {
|
for (int c = 0;c < cols;c++) {
|
int index = r * cols + c;
|
int start = index * 3;
|
uchar R = data[start];
|
uchar G = data[start + 1];
|
uchar B = data[start + 2];
|
grayData[index] = (76 * R + 150 * G + 30 * B) >> 8;
|
}
|
}
|
|
|
|
cv::Mat m = cv::Mat::zeros(mat.rows, mat.cols, CV_8UC1);
|
m.data = grayData;
|
imshow("黑白", m);
|
|
|
|
|
|
|
|
|
}
|
|
|
void ths() {
|
//00421530
|
cv::Mat img = CaptureUtil::capture(HWND(0x00040CAE));
|
img = ImgUtil::grayImage(img);
|
//cv::imwrite("C:\\Users\\Administrator\\Desktop\\ocr\\bk.jpg",img);
|
std::list<GPCodeArea> list = THSActionUtil::recognitionGPArea(img);
|
std::list<GPCodeArea>::iterator ele;
|
RecognitionManager* recognitionManager = new RecognitionManager();
|
int index = 0;
|
for (ele = list.begin();ele != list.end();ele++) {
|
index++;
|
GPCodeArea codeArea = *ele;
|
if (codeArea.type == IMG_TYPE_GP) {
|
cv::Mat nums = cv::Mat(img, cv::Rect(codeArea.startx, codeArea.starty, codeArea.endx - codeArea.startx + 1, codeArea.endy - codeArea.starty + 1));
|
std::list<cv::Mat> list2 = ImgUtil::splitNum(nums);
|
std::list<uchar> resultList = recognitionManager->recognitionGPCode(list2);
|
std::list<uchar>::iterator ele1;
|
printf("%d-", index);
|
for (ele1 = resultList.begin();ele1 != resultList.end();++ele1) {
|
printf("%d", *ele1);
|
}
|
printf("\n");
|
}
|
|
continue;
|
|
SetForegroundWindow(HWND(0x00161728));
|
SetFocus(HWND(0x00161728));
|
if (codeArea.type == IMG_TYPE_ADD) {
|
RECT rc;
|
GetWindowRect(HWND(0x00161728), &rc);
|
int y = rc.top + codeArea.starty + (codeArea.endy - codeArea.starty) / 2;
|
int x = rc.left + codeArea.startx + (codeArea.endx - codeArea.startx) / 2;
|
//POINT p;
|
//p.x = x;
|
//p.y = y;
|
//GetCursorPos(&p);
|
//移动鼠标
|
SetCursorPos(x, y);
|
Sleep(100);
|
//点击鼠标
|
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
Sleep(10);
|
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
|
//键盘输入
|
HANDLE hThread = CreateThread(NULL, 0, inputCode, 0, 0, NULL);
|
//system("PAUSE");
|
|
|
CreateThread(NULL, 0, inputEnter, 0, 0, NULL);
|
|
system("PAUSE");
|
|
//keybd_event(VK_RETURN, 0, 0, 0);
|
//keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
|
|
break;
|
}
|
}
|
|
|
|
}
|