# -*- coding: utf-8 -*-
"""
Created on Sat Mar 31 17:42:41 2018

@author: Administrator
"""

import clr
import sys
import os
import numpy as np
#import cv2
import System
import System.Drawing
import cv2
sys.path.append(r'C:\Users\Administrator\Documents\visual studio 2012\Projects\lmidll\lmidll\bin\x86\Release') 
clr.FindAssembly('lmidll.dll') 
clr.FindAssembly('GoSdk.dll') 
clr.FindAssembly('GoSdkNet.dll') 
clr.FindAssembly('kkApi.dll')
clr.FindAssembly('kApiNet.dll')
clr.AddReference('kApiNet')
clr.AddReference('GoSdkNet')
clr.AddReference('lmidll')
clr.AddReference('System.Drawing')
clr.AddReference('System.IO')
clr.FindAssembly('halcondotnet.dll')
clr.AddReference('HalconDotNet')
from HalconDotNet import *
 
ho_Image=HObject(())
ho_Image=HObject(())
ho_GrayImage=HObject(())
ho_Invert=HObject(())
ho_ImageConverted=HObject(())
#Local control variables 

#hv_AcqHandle=HTuple(()) 

# Initialize local and output iconic variables 
HOperatorSet.GenEmptyObj(ho_Image)
HOperatorSet.GenEmptyObj(ho_ImageConverted)
HOperatorSet.GenEmptyObj(ho_GrayImage)
HOperatorSet.GenEmptyObj(ho_Invert)

#Code generated by Image Acquisition 01

#HOperatorSet.OpenFramegrabber("GenICamTL", 1, 1, 0, 0, 0, 0, "progressive", 16,"rgb", -1, "false", "default", "192.168.1.10 producer:C:\\Users\\Administrator\\Desktop\\14405-4.7.12.116_SOFTWARE_GO_Tools\\GenTL\\x86\\Go2GenTL.cti interface:0:XX::GenTL vendor:LMI model:Gocator 2420",0, -1, hv_AcqHandle)
hv_AcqHandle＝
HOperatorSet.GrabImageStart(hv_AcqHandle, -1);
ho_Image.Dispose()
HOperatorSet.GrabImageAsync(ho_Image, hv_AcqHandle, -1)
#Do something
HOperatorSet.CloseFramegrabber(hv_AcqHandle);
#convert_image_type (Image, ImageConverted, 'unit2')
ho_GrayImage.Dispose();
HOperatorSet.Rgb1ToGray(ho_Image, ho_GrayImage);
ho_Invert.Dispose();
HOperatorSet.ScaleImage(ho_GrayImage, ho_Invert, 0.0192, 0);
ho_ImageConverted.Dispose();
HOperatorSet.ConvertImageType(ho_Invert, ho_ImageConverted, "byte");
HOperatorSet.WriteImage(ho_ImageConverted, "bmp", 0, "C:/Users/Administrator/Desktop/a.bmp");
ho_Image.Dispose();
ho_ImageConverted.Dispose();
ho_GrayImage.Dispose();
ho_Invert.Dispose();