赞
踩
先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7
深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新软件测试全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
如果你需要这些资料,可以添加V获取:vip1024b (备注软件测试)
1.从官网demo到idea中使用;
2.如何阅读官网的说明文档,小经验分享;
https://ai.baidu.com/ai-doc/index/OCR
https://ai.baidu.com/ai-doc/OCR/Ek3h7xypm
万里长征第一步,Ctrl c + v,复制粘贴
网络请求SDK案例
从官网的案例到spring项目整合
BaiduOcrPro实体类
package com.tianju.config.baidu;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* OCR相关的配置
*/
@Component
@ConfigurationProperties(prefix = “baidu.ocr”)
@PropertySource(“classpath:config/baiduAip.properties”)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaiduOcrPro {
private String appId;
private String apiKey;
private String secretKey;
}
初始化AipOcr,放到spring容器中
package com.tianju.config.baidu;
import com.baidu.aip.ocr.AipOcr;
import com.baidu.aip.speech.AipSpeech;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 百度相关的配置文件
*/
@Configuration
public class BaiduConfig {
@Autowired
private BaiduOcrPro baiduOcrPro;
/**
* 图像相关的 AipOcr
* @return AipOcr 放容器中
*/
@Bean
public AipOcr aipOcr(){
AipOcr aipOcr = new AipOcr(baiduOcrPro.getAppId(),
baiduOcrPro.getApiKey(),
baiduOcrPro.getSecretKey());
// 可选:设置网络连接参数
aipOcr.setConnectionTimeoutInMillis(2000);
aipOcr.setSocketTimeoutInMillis(60000);
return aipOcr;
}
}
controller层进行调用
package com.tianju.config.controller;
import com.baidu.aip.ocr.AipOcr;
import com.tianju.config.resp.HttpResp;
import com.tianju.config.util.baidu.Base64Util;
import com.tianju.config.util.baidu.FileUtil;
import com.tianju.config.util.baidu.HttpUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.net.URLEncoder;
import java.util.HashMap;
@RestController
@RequestMapping(“/api/baidu/ocr”)
public class BaiduOCRController {
@Autowired
private AipOcr aipOcr;
// http://124.70.138.34:9000/hello/1.jpg
@GetMapping(“/imgUrl”)
public HttpResp ocrFromImgUrl(String imgUrl){
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
options.put(“language_type”, “CHN_ENG”);
options.put(“detect_direction”, “true”);
options.put(“detect_language”, “true”);
options.put(“probability”, “true”);
/**
* 网络图像
*/
JSONObject res = aipOcr.basicGeneralUrl(
imgUrl,
options
);
/**
* {“words_result”:
* [{“probability”:{“average”:0.9994496107,“min”:0.9990026355,“variance”:1.469044975E-7},
* “words”:“爱我中华”}],
* “log_id”:1705920508293856573,“words_result_num”:1,“language”:3,“direction”:0}
*/
JSONArray wordsResult = (org.json.JSONArray)res.get(“words_result”);
JSONObject o = (JSONObject) wordsResult.get(0);
Object words = o.get(“words”);
System.out.println(words);
System.out.println(“######################”);
System.out.println(res.toString(2));
return HttpResp.success(words);
}
}
package com.tianju.config.controller;
import com.baidu.aip.ocr.AipOcr;
import com.tianju.config.resp.HttpResp;
import com.tianju.config.util.baidu.Base64Util;
import com.tianju.config.util.baidu.FileUtil;
import com.tianju.config.util.baidu.HttpUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.net.URLEncoder;
import java.util.HashMap;
@RestController
@RequestMapping(“/api/baidu/ocr”)
public class BaiduOCRController {
/**
* 以下为官网的案例,token的方式
* https://ai.baidu.com/ai-doc/OCR/zk3h7xz52
*/
public static String generalBasic() {
// 请求url
String url = “https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic”;
try {
// 本地文件路径
String filePath = “D:\Myprogram\springboot-workspace\spring-project\baidu-api\src\main\resources\static\ocr_test.jpg”;
byte[] imgData = FileUtil.readFileByBytes(filePath);
String imgStr = Base64Util.encode(imgData);
String imgParam = URLEncoder.encode(imgStr, “UTF-8”);
String param = “image=” + imgParam;
System.out.println(param);
// 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
String accessToken = “24.2f4d3e23a805ba89627472c38addcdcd.2592000.1698147302.282335-38781099”;
String result = HttpUtil.post(url, accessToken, param);
System.out.println(result);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
generalBasic();
}
}
package com.tianju.config.util.baidu;
/**
* Base64 工具类
*/
public class Base64Util {
private static final char last2byte = (char) Integer.parseInt(“00000011”, 2);
private static final char last4byte = (char) Integer.parseInt(“00001111”, 2);
private static final char last6byte = (char) Integer.parseInt(“00111111”, 2);
private static final char lead6byte = (char) Integer.parseInt(“11111100”, 2);
private static final char lead4byte = (char) Integer.parseInt(“11110000”, 2);
private static final char lead2byte = (char) Integer.parseInt(“11000000”, 2);
private static final char[] encodeTable = new char[]{‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘+’, ‘/’};
public Base64Util() {
}
public static String encode(byte[] from) {
StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3);
int num = 0;
char currentByte = 0;
int i;
for (i = 0; i < from.length; ++i) {
for (num %= 8; num < 8; num += 6) {
switch (num) {
case 0:
currentByte = (char) (from[i] & lead6byte);
currentByte = (char) (currentByte >>> 2);
case 1:
case 3:
case 5:
default:
break;
case 2:
currentByte = (char) (from[i] & last6byte);
break;
case 4:
currentByte = (char) (from[i] & last4byte);
currentByte = (char) (currentByte << 2);
if (i + 1 < from.length) {
currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6);
}
break;
case 6:
currentByte = (char) (from[i] & last2byte);
currentByte = (char) (currentByte << 4);
if (i + 1 < from.length) {
currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4);
}
}
to.append(encodeTable[currentByte]);
}
}
if (to.length() % 4 != 0) {
for (i = 4 - to.length() % 4; i > 0; --i) {
to.append(“=”);
}
}
return to.toString();
}
}
package com.tianju.config.util.baidu;
import java.io.*;
/**
* 文件读取工具类
*/
public class FileUtil {
/**
* 读取文件内容,作为字符串返回
*/
public static String readFileAsString(String filePath) throws IOException {
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注软件测试)
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
/**
* 文件读取工具类
*/
public class FileUtil {
/**
* 读取文件内容,作为字符串返回
*/
public static String readFileAsString(String filePath) throws IOException {
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注软件测试)
[外链图片转存中…(img-EQzAywcX-1713416309585)]
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。