WIN10 64-bit under VS2015 MFC directly add Halcon 12 CPP file for visual inspection

Source: Internet
Author: User

Near time began to contact Halcon, but in the VS2015 inside use, whether it is the configuration or production EXE files, are not as good as meaning.

Plus online tutorials a lot, after many tests, in fact there are many places without modification, if the modification too much also lost the meaning of directly add encapsulation.

My environment for WIN10 64-bit HALCON12 with 64-bit everywhere C + + files, VS2015 free shared edition.

(If you want to generate 32-bit, you need to halcon12 with 32-bit programs to export C + +, and need to switch the VC to X86 platform,

Library directory changed to C:\Program Files\mvtec\halcon-12.0\lib\x86sse2-win32;

Part fifth of the configuration, project properties--Configuration Properties--linker--input--Additional dependencies--add halconcpp.lib,

The halconcpp.lib here needs to be changed to C:\Program Files\mvtec\halcon-12.0\lib\x86sse2-win32\halconcpp.lib

Other places are the same as the 64-bit. )

Start here:

First, the VS2015 aspect

1, Mr. Cheng an MFC dialog box program, step slightly. (I have to Project name: TMD visual inspection)

VS Configuration:

2, first in the Configuration Manager, the platform changed to X64, because when the change here, all the following settings will be restored by default. All best to set here first.


3, Project Properties--Configuration Properties--VC + + directory--Include directory--add $ (halconroot) \include;$ (halconroot) \include\halconcpp;


4, Project Properties--Configuration Properties--VC + + Directory--Library directory--add $ (halconroot) \lib\$ (Halconarch);

(Figure Ibid.)
5, Project Properties--Configuration Properties--linker--input--Additional dependencies--add Halconcpp.lib

Configuration Complete!

Second, the actual operation of the part:

1, Halcon export C + + files, remember to use 64-bit export, I exported the file name is: VCDemo64.cpp

2. Add CPP to VS, in Explorer, source file--right--add--Existing item--find the last exported Halcon CPP file

3. New header file Hh.h, Resource Manager--header file--add--New Item--Select header file--name HH.H (whatever)

HH.H Add Content:

#pragma once#ifndef my_file_h_#define my_file_h_void  action (); #endif

4. Modify the dialog box Dlg CPP file,

Add header files and spaces (such as):

# "  HalconCpp.h""hh.h "
using namespace Halconcpp;

5, modify Halcon CPP file VCDemo64.cpp,

Add header files at the top:

" stdafx.h "

As of this, the solution is rebuilt and the compilation succeeds.

Third, add button activation.

1. Add a button to the VS Form dialog box

In the button event code, add the following: (This code is the CPP main function segment exported by Halcon)

voidCTMD Visual Inspection Dlg::onbnclickedbutton1 () {//TODO: Add control notification handler code hereSetsystem ("width", +); Setsystem ("Height", +);#ifDefined (_WIN32)Setsystem ("Use_window_thread","true");#elifDefined (__linux__)xinitthreads ();#endif#ifndef __apple__ Action ();#elseret=Apple_main (argc, argv);#endif    return;}

When you copy it over, return will call the police and delete it.

Rebuild the solution, compile successfully, run, click button, such as: (Product does not show)

Not to be continued.

WIN10 64-bit under VS2015 MFC directly add Halcon 12 CPP file for visual inspection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.