package cn.hmsoft.ai.identity;

import java.io.File;

import cn.hmsoft.ai.idcard.IdCardOcr;
import cn.hmsoft.ai.util.AiParamUtil;

public abstract class IdentityAI {
	private static IdentityAI ai = null;

	public static IdentityAI instance() {
		if (ai == null) {
			synchronized (IdCardOcr.class) {
				try {
					ai = (IdentityAI) Class.forName(AiParamUtil.IdentityAIClass).newInstance();
				} catch (Exception e) {
					try {
						ai = IdentityNoAI.class.newInstance();
					} catch (Exception ex) {

					}
				}
			}
		}
		return ai;
	}

	public IdentifiedResult verify(String idphoto_image_path, String id_card, String std_name) {
		return this.verifyByFile(new File(idphoto_image_path), id_card, std_name);

	}

	public IdentifiedResult verify(File idphoto_image_file, String id_card, String std_name) {
		return verify(idphoto_image_file.getPath(), id_card, std_name);
	}
	
	public IdentifiedResult verify(File id_photo, File snap_photo) {
		return this.verifyFiles(id_photo, snap_photo);
	}
	public IdentifiedResult verify(String url1, String url2) {
		return this.verifyFiles(url1, url2);
	}
	

	protected abstract IdentifiedResult verifyByFile(File file, String id_card, String std_name);
	
	protected abstract IdentifiedResult verifyFiles(File sourceFile, File destFile);
	
	protected abstract IdentifiedResult verifyFiles(String url1, String url2);
}
