opencv使用鼠标选取Rect初始化目标.docx
《opencv使用鼠标选取Rect初始化目标.docx》由会员分享,可在线阅读,更多相关《opencv使用鼠标选取Rect初始化目标.docx(42页珍藏版)》请在冰豆网上搜索。
opencv使用鼠标选取Rect初始化目标
SYCarousel(实现无限轮播)
DTouch功能的应用
AFNetworking更改请求时间iOS
IOScrc校验
[文件]TableDataPanel.java~7KB
packagecom.yisin.cf.form;
iOSUIImageView动画
importjava.awt.Color;
importjava.awt.Dimension;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.util.List;
importjava.util.Map;
importjava.util.Vector;
iOS关于改变图片背景色image属性UIImageRenderingM...
importjavax.swing.BorderFactory;
importjavax.swing.JButton;
importjavax.swing.JLabel;
importjavax.swing.JScrollPane;
importjavax.swing.JTable;
importjavax.swing.JTextArea;
importjavax.swing.UIManager;
importjavax.swing.plaf.InsetsUIResource;
importjavax.swing.table.DefaultTableCellRenderer;
importjavax.swing.table.DefaultTableModel;
iOS简单的存储和读取本地图片适用于用户头像
importcom.yisin.cf.db.DBHelper;
importcom.yisin.cf.util.SQLFormatter;
IOS的JSON反序列化Demo
publicclassTableDataPanelextendsBasePanel{
IOS开发-AFNetworking测试Demo
privateStringsql="";
privateStringtableName="";
privateintwidth=900,height=600;
IOS开发NSSession断点续传Demo
publicTableDataPanel(intwidth,intheight){
this.width=width;
this.height=height;
initCommpant();
}
[代码][GoogleGo]代码
packagemain
import(
"io/ioutil"
"net/http"
"net/"
"fmt"
"encoding/json"
)
//----------------------------------
//黄金数据调用示例代码-聚合数据
//在线接口文档:
www/docs/29
//----------------------------------
IOS开发-AFNetworking测试Demo
constAPPKEY="*******************"//您申请的APPKEY
funcmain(){
//1.上海黄金交易所
Request1()
//2.上海期货交易所
Request2()
//3.银行账户黄金
Request3()
}
//1.上海黄金交易所
funcRequest1(){
//请求地址
juhe:
="web:
8080/finance/gold/shgold"
//初始化参数
param:
=.Values{}
//配置请求参数,方法内部已处理encode问题,中文参数可以直接传参
param.Set("key",APPKEY)//APPKey
param.Set("v","")//JSON格式版本(0或1)默认为0
//发送请求
data,err:
=Get(juhe,param)
iferr!
=nil{
fmt.Errorf("请求失败,错误信息:
\r\n%v",err)
}else{
varnetReturnmap[string]interface{}
json.Unmarshal(data,&netReturn)
ifnetReturn["error_code"].(float64)==0{
fmt.Printf("接口返回result字段是:
\r\n%v",netReturn["result"])
}
}
}
//2.上海期货交易所
funcRequest2(){
//请求地址
juhe:
="web:
8080/finance/gold/shfuture"
//初始化参数
param:
=.Values{}
//配置请求参数,方法内部已处理encode问题,中文参数可以直接传参
param.Set("key",APPKEY)//APPKey
param.Set("v","")//JSON格式版本(0或1)默认为0
//发送请求
data,err:
=Get(juhe,param)
iferr!
=nil{
fmt.Errorf("请求失败,错误信息:
\r\n%v",err)
}else{
varnetReturnmap[string]interface{}
json.Unmarshal(data,&netReturn)
ifnetReturn["error_code"].(float64)==0{
fmt.Printf("接口返回result字段是:
\r\n%v",netReturn["result"])
}
}
}
//3.银行账户黄金
funcRequest3(){
//请求地址
juhe:
="web:
8080/finance/gold/bankgold"
//初始化参数
param:
=.Values{}
//配置请求参数,方法内部已处理encode问题,中文参数可以直接传参
param.Set("key",APPKEY)//APPKey
//发送请求
data,err:
=Get(juhe,param)
iferr!
=nil{
fmt.Errorf("请求失败,错误信息:
\r\n%v",err)
}else{
varnetReturnmap[string]interface{}
json.Unmarshal(data,&netReturn)
ifnetReturn["error_code"].(float64)==0{
fmt.Printf("接口返回result字段是:
\r\n%v",netReturn["result"])
}
}
}
//get网络请求
funcGet(apistring,params.Values)(rs[]byte,errerror){
var*.
err=.Parse(api)
iferr!
=nil{
fmt.Printf("解析错误:
\r\n%v",err)
returnnil,err
}
//如果参数中有中文参数,这个方法会进行Encode
.RawQuery=params.Encode()
resp,err:
=http.Get(.String())
iferr!
=nil{
fmt.Println("err:
",err)
returnnil,err
}
deferresp.Body.Close()
returnioutil.ReadAll(resp.Body)
}
//post网络请求,params是.Values类型
funcPost(apistring,params.Values)(rs[]byte,errerror){
resp,err:
=http.PostForm(api,params)
iferr!
=nil{
returnnil,err
}
deferresp.Body.Close()
returnioutil.ReadAll(resp.Body)
}
代码描述:
基于GO的黄金数据接口调用代码实例
关联数据:
黄金数据
[代码][C#]代码
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Net;
usingSystem.IO;
usingXfrog.Net;
usingSystem.Diagnostics;
usingSystem.Web;
//----------------------------------
//黄金数据调用示例代码-聚合数据
//在线接口文档:
www/docs/29
//代码中JsonObject类下载地址:
/download/gcm3206021155665/7458439
//----------------------------------
namespaceConsoleAPI
{
classProgram
{
staticvoidMain(string[]args)
{
stringappkey="*******************";//配置您申请的appkey
//1.上海黄金交易所
string1="web:
8080/finance/gold/shgold";
varparameters1=newDictionary();
parameters1.Add("key",appkey);//你申请的key
parameters1.Add("v","");//JSON格式版本(0或1)默认为0
stringresult1=sendPost(1,parameters1,"get");
JsonObjectnewObj1=newJsonObject(result1);
StringerrorCode1=newObj1["error_code"].Value;
if(errorCode1=="0")
{
Debug.WriteLine("成功");
Debug.WriteLine(newObj1);
}
else
{
//Debug.WriteLine("失败");
Debug.WriteLine(newObj1["error_code"].Value+":
"+newObj1["reason"].Value);
}
//2.上海期货交易所
string2="web:
8080/finance/gold/shfuture";
varparameters2=newDictionary();
parameters2.Add("key",appkey);//你申请的key
parameters2.Add("v","");//JSON格式版本(0或1)默认为0
stringresult2=sendPost(2,parameters2,"get");
JsonObjectnewObj2=newJsonObject(result2);
StringerrorCode2=newObj2["error_code"].Value;
if(errorCode2=="0")
{
Debug.WriteLine("成功");
Debug.WriteLine(newObj2);
}
else
{
//Debug.WriteLine("失败");
Debug.WriteLine(newObj2["error_code"].Value+":
"+newObj2["reason"].Value);
}
//3.银行账户黄金
string3="web:
8080/finance/gold/bankgold";
varparameters3=newDictionary();
parameters3.Add("key",appkey);//你申请的key
stringresult3=sendPost(3,parameters3,"get");
JsonObjectnewObj3=newJsonObject(result3);
StringerrorCode3=newObj3["error_code"].Value;
if(errorCode3=="0")
{
Debug.WriteLine("成功");
Debug.WriteLine(newObj3);
}
else
{
//Debug.WriteLine("失败");
Debug.WriteLine(newObj3["error_code"].Value+":
"+newObj3["reason"].Value);
}
}
///
///Http(GET/POST)
///
///请求
///请求参数
///请求方法
///响应内容
staticstringsendPost(string,IDictionaryparameters,stringmethod)
{
if(method.ToLower()=="post")
{
HttpWebRequestreq=null;
HttpWebResponsersp=null;
System.IO.StreamreqStream=null;
try
{
req=(HttpWebRequest)WebRequest.Create();
req.Method=method;
req.KeepAlive=false;
req.ProtocolVersion=HttpVersion.Version10;
req.Timeout=5000;
req.ContentType="application/x-www-form-encoded;charset=utf-8";
byte[]postData=Encoding.UTF8.GetBytes(BuildQuery(parameters,"utf8"));
reqStream=req.GetRequestStream();
reqStream.Write(postData,0,postData.Length);
rsp=(HttpWebResponse)req.GetResponse();
Encodingencoding=Encoding.GetEncoding(rsp.CharacterSet);
returnGetResponseAsString(rsp,encoding);
}
catch(Exceptionex)
{
returnex.Message;
}
finally
{
if(reqStream!
=null)reqStream.Close();
if(rsp!
=null)rsp.Close();
}
}
else
{
//创建请求
HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(+"?
"+BuildQuery(parameters,"utf8"));
//GET请求
request.Method="GET";
request.ReadWriteTimeout=5000;
request.ContentType="text/html;charset=UTF-8";
HttpWebResponseresponse=(HttpWebResponse)request.GetResponse();
StreammyResponseStream=response.GetResponseStream();
StreamReadermyStreamReader=newStreamReader(myResponseStream,Encoding.GetEncoding("utf-8"));
//返回内容
stringretString=myStreamReader.ReadToEnd();
returnretString;
}
}
///
///组装普通文本请求参数。
///
///Key-Value形式请求参数字典
///编码后的请求数据
staticstringBuildQuery(IDictionaryparameters,stringencode)
{
StringBuilderpostData=newStringBuilder();
boolhasParam=false;
IEnumerator>dem=parameters.GetEnumerator();
while(dem.MoveNext())
{
stringname=dem.Current.Key;
stringvalue=dem.Current.Value;
//忽略参数名或参数值为空的参数
if(!
string.IsNullOrEmpty(name))//&&!
string.IsNullOrEmpty(value)
{
if(hasParam)
{
postData.Append("&");
}
postData.Append(name);
postData.Append("=");
if(encode=="gb2312")
{
postData.Append(HttpUtility.Encode(value,Encoding.GetEncoding("gb2312")));
}
elseif(encode=="utf8")
{
postData.Append(HttpUtility.Encode(value,Encoding.UTF8));
}
else
{
postData.Append(value);
}
hasParam=true;
}
}
returnpostData.ToString();
}
///
///把响应流转换为文本。
///
///响应流对象
///编码方式
///响应文本
staticstringGetResponseAsString(HttpWebResponsersp,Encodingencoding)
{
System.IO.Streamstream=null;
StreamReaderreader=null;
try
{
//以字符流的方式读取HTTP响应
stream=rsp.GetResponseStream();
reader=newStreamReader(stream,encoding);
returnreader.ReadToEnd();
}
finally
{
//释放资源
if(reader!
=null)reader.Close();
if(stream!
=null)stream.Close();
if(rsp!
=null)rsp.Close();
}
}
}
}
[代码][PHP]代码
/**
*c远程传输工具
*/
publicfunctionpost_c($,$body,$header,$type='POST'){
$ch=c_init();
c_setopt($ch,COPT_,$);
c_setopt($ch,COPT_HEADER,0);//0只要正文
c_setopt($ch,COPT_TIMEOUT,5);//设置超时时间
c_setopt($ch,COPT_CONNECTTIMEOUT,5);
//将c_exec()获取的信息以文件流的形式返回,而不是直接输出。
c_setopt($ch,COPT_RETURNTRANSFER,1);
//增加header头信息
//array_push($header,'Accept:
application/json');
//array_push($header,'Content-Type:
application/json');
//array_push($header,'http:
multipart/form-data');
if(count($body)>0){
c_setopt($ch,COPT_POSTFIELDS,$body);
}
if(count($header)>0){
c_setopt($ch,COPT_HTTPHEADER,$header);
}
//设置上传文件相关
c_setopt($ch,COPT_FOLLOWLOCATION,true);
c_setopt($ch,COPT_MAXREDIRS,3);//递归
c_setopt($ch,COPT_SSL_VERIFYPEER,false);//对认证证书来源