记一次OJ在线代码编辑器(代码编译+运行,C、C++、Java)

news2024/10/5 20:26:24

如何在SpringBoot+Vue的项目中实现在线代码编译及执行(支持编译运行C、C++、Java),研究了一天,真实能用,下面直接上源码!!!

——————————————————————————————————————————

一、后端(直接接收字符串进行代码编译)

(1)C编译执行方法(直接调用,传入字符串即可完成编译)

package complier.complier_c;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

import complier.util.FileUtil;

/**
 * C编译器
 * @author tpw
 *
 */
public class CComplier {
	
	private final static String CplusplusFILEPATH=System.getProperty("user.dir") + "\\cCode\\";
	private final static String CplusplusFILENAME="main.c";
	private final static String CplusplusEXE="main.exe";
	
	private String inputData; //输入数据
	private String outputData; //输出数据
	private String errorMsg; //程序错误信息
	
	public CComplier() {
		this.inputData="";
		this.errorMsg="";
	}
	public CComplier(String inputData) {
		super();
		this.inputData = inputData;
		this.errorMsg="";
	}
	public CComplier(String inputData, String outputData, String errorMsg) {
		super();
		this.inputData = inputData;
		this.outputData = outputData;
		this.errorMsg = errorMsg;
	}
	
	public void complier() {
		// 这里调用执行写入工具类,其他两个好像没写,这里给出个demo
		FileUtil.writeFile(inputData,CplusplusFILEPATH+CplusplusFILENAME);
		// 进入c代码存放文件夹
		// 使用gcc命令来编译c文件,来生成一个exe文件
		// 直接运行exe文件

		// cmd命令:cd /d d:\javaworkspace\complier\cCode
		// cmd命令:gcc main.cpp
		// cmd命令:main.exe
		StringBuffer errorInfo = new StringBuffer();
		Process p=null;
		try {
			//1.编译C++文件
			p = Runtime.getRuntime().exec("gcc "+CplusplusFILEPATH+CplusplusFILENAME+" -o "+CplusplusFILEPATH+"main");
			// 获取进程的错误流
			final InputStream is1 = p.getErrorStream();
			// 开一个线程,读标准错误流
			new Thread() {
				public void run() {
					try {
						BufferedReader br1 = new BufferedReader(new InputStreamReader(is1,Charset.forName("GBK")));
						String line1 = null;
						while ((line1 = br1.readLine()) != null) {
							if (line1 != null) {
								errorInfo.append(line1 + "\n");
							}
						}
						if(!errorInfo.toString().equals("")) {
							errorMsg=errorInfo.toString();
						}
					} catch (IOException e) {
						e.printStackTrace();
					} finally {
						try {
							is1.close();
						} catch (IOException e) {
							e.printStackTrace();
						}
					}
				}
			}.start();
			p.waitFor();
			p.destroy();
			//2.如果没错的话就运行exe文件
			if (errorInfo.toString().equals("")) {
				try {
					Process process = Runtime.getRuntime().exec(CplusplusFILEPATH+CplusplusEXE);
					BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
			        bout.write(this.inputData);
			        bout.close();
					BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(),Charset.forName("GBK")));
					String line = null;
					StringBuffer b = new StringBuffer();
					while ((line = br.readLine()) != null) {
						b.append(line + "\n");
					}
					this.outputData=b.toString();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		} catch (Exception e) {
			try {
				p.getErrorStream().close();
				p.getInputStream().close();
				p.getOutputStream().close();
			} catch (Exception ee) {
				ee.printStackTrace();
			}
		}
	}
	
	public String getInputData() {
		return inputData;
	}
	public void setInputData(String inputData) {
		this.inputData = inputData;
	}
	public String getOutputData() {
		return outputData;
	}
	public void setOutputData(String outputData) {
		this.outputData = outputData;
	}
	public String getErrorMsg() {
		return errorMsg;
	}
	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}
}

(2)C++编译执行方法(直接调用,传入字符串即可完成编译)

package complier.complier_cplusplus;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

/**
 * C++编译器
 * @author tpw
 *
 */
public class CplusplusComplier {
	
	private final static String CplusplusFILEPATH=System.getProperty("user.dir") + "\\c++Code\\";
	private final static String CplusplusFILENAME="main.cpp";
	private final static String CplusplusEXE="main.exe";
	
	private String inputData; //输入数据
	private String outputData; //输出数据
	private String errorMsg; //程序错误信息
	
	public CplusplusComplier() {
		this.inputData="";
		this.errorMsg="";
	}
	public CplusplusComplier(String inputData) {
		super();
		this.inputData = inputData;
		this.errorMsg="";
	}
	public CplusplusComplier(String inputData, String outputData, String errorMsg) {
		super();
		this.inputData = inputData;
		this.outputData = outputData;
		this.errorMsg = errorMsg;
	}
	
	public void complier() {
		// 进入c++代码存放文件夹
		// 使用g++命令来编译c++文件,来生成一个exe文件
		// 直接运行exe文件

		// cmd命令:cd /d d:\javaworkspace\complier\c++Code
		// cmd命令:g++ main.cpp
		// cmd命令:main.exe
		StringBuffer errorInfo = new StringBuffer();
		Process p=null;
		try {
			//1.编译C++文件
			p = Runtime.getRuntime().exec("g++ "+CplusplusFILEPATH+CplusplusFILENAME+" -o "+CplusplusFILEPATH+"main");
			// 获取进程的错误流
			final InputStream is1 = p.getErrorStream();
			// 开一个线程,读标准错误流
			new Thread() {
				public void run() {
					try {
						BufferedReader br1 = new BufferedReader(new InputStreamReader(is1,Charset.forName("GBK")));
						String line1 = null;
						while ((line1 = br1.readLine()) != null) {
							if (line1 != null) {
								errorInfo.append(line1 + "\n");
							}
						}
						if(!errorInfo.toString().equals("")) {
							errorMsg=errorInfo.toString();
						}
					} catch (IOException e) {
						e.printStackTrace();
					} finally {
						try {
							is1.close();
						} catch (IOException e) {
							e.printStackTrace();
						}
					}
				}
			}.start();
			p.waitFor();
			p.destroy();
			//2.如果没错的话就运行exe文件
			if (errorInfo.toString().equals("")) {
				try {
					Process process = Runtime.getRuntime().exec(CplusplusFILEPATH+CplusplusEXE);
					BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
			        bout.write(this.inputData);
			        bout.close();
					BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(),Charset.forName("GBK")));
					String line = null;
					StringBuffer b = new StringBuffer();
					while ((line = br.readLine()) != null) {
						b.append(line + "\n");
					}
					this.outputData=b.toString();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		} catch (Exception e) {
			try {
				p.getErrorStream().close();
				p.getInputStream().close();
				p.getOutputStream().close();
			} catch (Exception ee) {
				ee.printStackTrace();
			}
		}
	}
	
	public String getInputData() {
		return inputData;
	}
	public void setInputData(String inputData) {
		this.inputData = inputData;
	}
	public String getOutputData() {
		return outputData;
	}
	public void setOutputData(String outputData) {
		this.outputData = outputData;
	}
	public String getErrorMsg() {
		return errorMsg;
	}
	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}
}

(3)Java编译执行方法(直接调用,传入字符串即可完成编译)

package complier.complier_java;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

/**
 * java编译器
 * @author tpw
 *
 */
public class JavaComplier {
	
	private final static String jAVAFILEPATH=System.getProperty("user.dir") + "\\javaCode";
	private final static String JAVAFILENAME="Main.java";
	private final static String jAVAFILECLASNAME="Main";
	
	private String inputData; //输入数据
	private String outputData; //输出数据
	private String errorMsg; //程序错误信息
	
	public JavaComplier() {
		this.inputData="";
		this.errorMsg="";
	}
	public JavaComplier(String inputData) {
		super();
		this.inputData = inputData;
		this.errorMsg="";
	}
	public JavaComplier(String inputData, String outputData, String errorMsg) {
		super();
		this.inputData = inputData;
		this.outputData = outputData;
		this.errorMsg = errorMsg;
	}
	
	public void complier() {
		// 进入java代码存放文件夹
		// 使用javac命令来编译java文件,来生成一个class文件
		// 使用java命令来运行类

		// cmd命令:cd /d d:\javaworkspace\complier\javaCode
		// cmd命令:javac Main.java
		// cmd命令:java Main
		StringBuffer errorInfo = new StringBuffer();
		Process p=null;
		try {
			//1.编译java文件
			p = Runtime.getRuntime().exec("javac "+JAVAFILENAME, null, new File(jAVAFILEPATH));
			// 获取进程的错误流
			final InputStream is1 = p.getErrorStream();
			// 开一个线程,读标准错误流
			new Thread() {
				public void run() {
					try {
						BufferedReader br1 = new BufferedReader(new InputStreamReader(is1,Charset.forName("GBK")));
						String line1 = null;
						while ((line1 = br1.readLine()) != null) {
							if (line1 != null) {
								errorInfo.append(line1 + "\n");
							}
						}
						if(!errorInfo.toString().equals("")) {
							errorMsg=errorInfo.toString();
						}
					} catch (IOException e) {
						e.printStackTrace();
					} finally {
						try {
							is1.close();
						} catch (IOException e) {
							e.printStackTrace();
						}
					}
				}
			}.start();
			p.waitFor();
			p.destroy();
			//2.如果没错的话就运行java文件
			if (errorInfo.toString().equals("")) {
				try {
					Process process = Runtime.getRuntime().exec("java "+jAVAFILECLASNAME, null, new File(jAVAFILEPATH));
					BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
			        bout.write(this.inputData);
			        bout.close();
					BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(),Charset.forName("GBK")));
					String line = null;
					StringBuffer b = new StringBuffer();
					while ((line = br.readLine()) != null) {
						b.append(line + "\n");
					}
					this.outputData=b.toString();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		} catch (Exception e) {
			try {
				p.getErrorStream().close();
				p.getInputStream().close();
				p.getOutputStream().close();
			} catch (Exception ee) {
				ee.printStackTrace();
			}
		}
	}
	
	public String getInputData() {
		return inputData;
	}
	public void setInputData(String inputData) {
		this.inputData = inputData;
	}
	public String getOutputData() {
		return outputData;
	}
	public void setOutputData(String outputData) {
		this.outputData = outputData;
	}
	public String getErrorMsg() {
		return errorMsg;
	}
	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}
}

(4)字符串写入工具类(直接调用,传入字符串即可完成写入)

package complier.util;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class FileUtil {

	public static void writeFile(String content,String filePath) {
         try {
        	 BufferedWriter out = new BufferedWriter(new FileWriter(filePath));
        	 out.write(content);
        	 out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}    
	}
}

(5)测试调用Demo

package complier.complier_java;

public class Test {
	
	public static void main(String[] args) {
        // 这里调用的Java编译,其他类同
		JavaComplier javaComplier=new JavaComplier("Hello!!");
		javaComplier.complier();
		String proError=javaComplier.getErrorMsg();
		if(!proError.equals("")) {
			System.err.println(proError);
		}else {
			System.out.println(javaComplier.getOutputData());
		}
	}
}


二、前端(输入字符串,简单的直接输入框,复杂点就用ACE插件或者其他,此案例使用的ACE)

js引入方式可以采取以下方式,推荐本地下载包引入:

        在线js引入举例(这两个是可以用的):     

     <script src="http://cdn.bootcss.com/ace/1.2.4/ace.js"></script>
     <script src="http://cdn.bootcss.com/ace/1.2.4/ext-language_tools.js"></script>

        本地js引入举例:     

     <script src="/codemirror/src-noconflict/ace.js"></script>
 

<template>
  <div class="Ace">
    <div class="code_tool_bar">
      <span style="position: relative;left: 10px; top: 16px; font-size: 18px;">这个要比我写的样式要好(复制别人的)</span>
      <el-button icon="el-icon-s-tools" @click="dialogTableVisible = true" style="float: right;margin: 10px;"></el-button>
      <el-button icon="el-icon-refresh" @click="refresh_code" style="float: right; margin: 10px;"></el-button>
      <el-select v-model="selectLanguageValue" @change="changSelectValue1" filterable style="float: right;margin: 10px;">
        <el-option
          v-for="item in languagesOptions"
          :key="item.label"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
      <el-dialog :visible.sync="dialogTableVisible"
                 :append-to-body="true"
                 top="40px"
                 width="39.194%"
                 :destroy-on-close="true"
                 :show-close="false"
                 custom-class="code-editor-config-dialog">
        <el-card style="margin: -59px -20px 0 -20px;"
                 shadow="never">
          <div slot="header" class="clearfix">
            <span>代码编辑器设置</span>
            <el-button style="float: right; padding: 3px 0" type="text" @click="dialogTableVisible = false">x</el-button>
          </div>
          <div class="row">
            <el-row>
              <el-col :span="16">
                <div class="code-editor-option-title">主题</div>
                <div class="code-editor-option-description">对白色界面感到厌倦了吗?可以尝试其他的背景和代码高亮风格。</div>
              </el-col>
              <el-col :span="8">
                <el-select v-model="selectThemeValue"
                           @change="changSelectValue"
                           filterable>
                  <el-option
                    v-for="item in themesOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-col>
            </el-row>
            <hr>
          </div>
          <div class="row">
            <el-row>
              <el-col :span="16">
                <div class="code-editor-option-title">编辑类型</div>
                <div class="code-editor-option-description">更喜欢Vim或者Emacs的输入方式吗?我们也为你提供了这些选项。</div>
              </el-col>
              <el-col :span="8">
                <el-select v-model="selectEditorValue"
                           @change="setEditorMode"
                           filterable>
                  <el-option
                    v-for="item in editorOption"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-col>
            </el-row>
            <hr>
          </div>
          <div class="row">
            <el-row>
              <el-col :span="16">
                <div class="code-editor-option-title">缩进长度</div>
                <div class="code-editor-option-description">选择代码缩进的长度。默认是4个空格。</div>
              </el-col>
              <el-col :span="8">
                <el-select v-model="selectTabValue"
                           @change="setTabSize"
                           filterable>
                  <el-option
                    v-for="item in tabOption"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-col>
            </el-row>
            <hr>
          </div>
          <div class="row">
            <el-row>
              <el-col :span="16">
                <div class="code-editor-option-title">主题</div>
                <div class="code-editor-option-description">对白色界面感到厌倦了吗?可以尝试其他的背景和代码高亮风格。</div>
              </el-col>
              <el-col :span="8">
                <el-select v-model="selectThemeValue"
                           @change="changSelectValue"
                           filterable>
                  <el-option
                    v-for="item in themesOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-col>
            </el-row>
          </div>
        </el-card>
        <el-button @click="dialogTableVisible = false" style="margin: 20px 480px -12px 480px">确 定</el-button>
      </el-dialog>
    </div>
    <div ref="ace" class="ace"></div>
    <el-button class="submitBtn" round type="success" ><i class="fa fa-cloud-upload" aria-hidden="true"></i>提交代码</el-button>
    <el-button class="debuggerBtn" round @click="debuggerCode" ><i class="fa fa-play-circle-o" aria-hidden="true"></i>调试代码</el-button>
  </div>
</template>

<script>
import ace from 'ace-builds'
import 'ace-builds/webpack-resolver'; // 在 webpack 环境中使用必须要导入
//解决添加提示时控制台警告(提示必须引入的包)
import "ace-builds/src-noconflict/ext-language_tools"
import "ace-builds/src-noconflict/ext-emmet"
//语言提示
import 'ace-builds/src-noconflict/snippets/javascript'
import 'ace-builds/src-noconflict/snippets/c_cpp'
import 'ace-builds/src-noconflict/snippets/java'
import 'ace-builds/src-noconflict/snippets/golang'
import 'ace-builds/src-noconflict/snippets/python'
//输入类型
import 'ace-builds/src-noconflict/keybinding-emacs'
import 'ace-builds/src-noconflict/keybinding-vim'
import 'ace-builds/src-noconflict/keybinding-vscode'

export default {
  name: 'CodeEditor',
  props: {
    value: {
      type: String,
      required: true
    }
  },
  methods: {
    changSelectValue(value) {
      this.aceEditor.setTheme(`ace/theme/${value}`);
    },
    refresh_code() {
      this.aceEditor.session.setValue('');
    },
    changSelectValue1(value) {
      this.aceEditor.session.setMode(`ace/mode/${value}`);
    },
    debuggerCode() {
      let value = this.aceEditor.session.getValue();
      console.log(value);
    },
    setTabSize(size) {
      this.aceEditor.session.setTabSize(size);
    },
    setEditorMode(value) {
      this.aceEditor.setKeyboardHandler(`ace/keyboard/${value}`);
    }
  },
  data() {
    return {
      dialogTableVisible: false,
      themeValue: 'ambiance',
      aceEditor: null,
      themePath: 'ace/theme/monokai', // 不导入 webpack-resolver,该模块路径会报错
      modePath: 'ace/mode/c_cpp', // 同上
      codeValue: this.value || '',
      editorOption:[{
        value: 'vscode',
        label: 'Standard'
      },{
        value: 'vim',
        label: 'Vim'
      },{
        value: 'emacs',
        label: 'Emacs'
      }],
      selectEditorValue: 'Standard',
      tabOption:[{
        value: '2',
        label: '2个空格'
      },{
        value: '4',
        label: '4个空格'
      },{
        value: '6',
        label: '6个空格'
      }],
      selectTabValue: '4个空格',
      themesOptions: [{
        value: 'crimson_editor',
        label: 'CrimsonEditor'
      },{
        value: 'monokai',
        label: 'Monokai'
      },{
        value: 'terminal',
        label: 'Terminal'
      },{
        value: 'xcode',
        label: 'Xcode'
      }],
      selectThemeValue: 'Monokai',
      languagesOptions: [{
        value: 'c_cpp',
        label: 'C++'
      },{
        value: 'c_cpp',
        label: 'C'
      },{
        value: 'java',
        label: 'Java'
      },{
        value: 'golang',
        label: 'Golang'
      },{
        value: 'python',
        label: 'Python'
      },{
        value: 'javascript',
        label: 'Javascript'
      }],
      selectLanguageValue: 'C++'
    };
  },
  mounted() {
    this.aceEditor = ace.edit(this.$refs.ace,{
      maxLines: 1000, // 最大行数,超过会自动出现滚动条
      minLines: 22, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
      fontSize: 14, // 编辑器内字体大小
      theme: this.themePath, // 默认设置的主题
      mode: this.modePath, // 默认设置的语言模式
      tabSize: 4, // 制表符设置为 4 个空格大小
      readOnly: false, //只读
      highlightActiveLine: true,
      value: this.codeValue
    });
    this.aceEditor.setOptions({
      enableSnippets: true,
      enableLiveAutocompletion: true,
      enableBasicAutocompletion: true
    });
    // 快捷键
    // this.aceEditor.commands.addCommand({
    //   name: 'myCommand',
    //   bindKey: {win: 'Ctrl-M',  mac: 'Command-M'},
    //   exec: function(editor) {
    //     //...
    //   },
    //   readOnly: true // false if this command should not apply in readOnly mode
    // });
  },
  watch: {
    value(newVal) {
      console.log(newVal);
      this.aceEditor.setValue(newVal);
    }
  }
};
</script>

<style scoped lang="scss">
.code_tool_bar {
  height: 60px;
  width: 100%;
  background: #f8f9fa;
  border: 1px solid #c2c7d0;
  margin-bottom: 0;
}

.code-editor-option-title {
  font-size: 17px;
  margin-bottom: 10px;
}

.code-editor-option-description {
  font-size: 13px;
  color: grey;
}

hr {
  background: none !important;
  height: 1px !important;
  border: 0 !important;
  border-top: 1px solid #eee !important;
  margin-top: 20px;
  margin-bottom: 20px;
}

.ace {
  position: relative !important;
  border: 1px solid lightgray;
  margin: auto;
  height: auto;
  width: 100%;
}
.debuggerBtn {
  float: right;
  margin: 13px 20px 0 0;
}
.submitBtn {
  float: right;
  margin: 13px 0 0 0;
}
</style>

效果截图 :

三、编译执行代码还需要在项目的src同级目录下创建对应的编译文件夹,用于接收字符串写入并执行。下面放出目录截图,直接用记事本创建并更改扩展名即可,文件里面的内容都是空的。

四、此项目总体截图

输入代码(C):

代码执行结果:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/493348.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

MySQL 知识:迁移数据目录到其他路径

一、系统环境 操作系统&#xff1a;Centos 7 已安装环境&#xff1a;MySQL 8.0.26 二、开始操作 2.1 关闭SELinux 为了提高 Linux 系统的安全性&#xff0c;在 Linux 上通常会使用 SELinux 或 AppArmor 实现强制访问控制&#xff08;Mandatory Access Control MAC&#xff…

中间件的概念

中间件(middleware)是基础软件的一大类&#xff0c;属于可复用的软件范畴。中间件在操作系统软件&#xff0c;网络和数据库之上&#xff0c;应用软件之下&#xff0c;总的作用是为处于自己上层的应用软件提供运行于开发的环境&#xff0c;帮助用户灵活、高效的开发和集成复杂的…

阶段二38_面向对象高级_网络编程[UDP单播组播广播代码实现]

知识&#xff1a; InetAddresss:getByName,getHostName,getHostAddress方法UDP通信程序&#xff1a;单播&#xff0c;组播&#xff0c;广播代码实现一.InetAddress 的使用 1.static InetAddress getByName(String host) 确定主机名称的IP地址。主机名称可以是机器名称&#x…

【Java】通过反射方法不改变HashCode以修改String的值

如何修改String的值&#xff1f; 我们首先会想到如下两种方法 方式一&#xff1a;通过StringBuild/StringBuffer String s1 "Hello World!"; System.out.println("s1"s1" HashCode"s1.hashCode()); StringBuilder sb new StringBuilder(s1…

Android JNI配置CMakeLists.txt修改.cpp在logcat打印日志

Android JNI配置CMakeLists.txt修改.cpp在logcat打印日志 C/C代码里面常用的printf没法在Android 的logcat输出显示。需要特别配置C才能显示在logcat里面。 &#xff08;1&#xff09;CMakeLists.txt定义&#xff1a; find_library( # Sets the name of the path variable.l…

yolov1原理

目标检测方法 传统的方法可以按照检测系统分为两种&#xff1a; DPM&#xff0c;Deformatable Parts Models&#xff0c;采用sliding window检测R-CNN、Fast R-CNN。采用region proposal的方法&#xff0c;生成一些可能包含待检测物体的potential bounding box&#xff0c;再…

opencv_c++学习(三)

一、获取图像像素指针 CV Assert(mylmage.depth() CV 8U); CV_Assert()函数判断图像数据的类型是否为uchar类型&#xff0c;不满足则抛出异常。 Mat.ptr(int i0)获取像素矩阵的指针&#xff0c;索引i表示第几行&#xff0c;从0开始计行数。 Mat.ptr(int i0)获取像素矩阵的指针…

【五一创作】【远程工具】- Tabby 下载、安装、使用、配置【ssh/Serial】-免安装、解压即用

目录 一、Tabby 概述 二、Tabby 下载、安装 三、Tabby 的使用  &#x1f449;3.1 使用SSH协议连接Linux开发主机  &#x1f449;3.2 使用Serial(串口)协议连接开发板 一、Tabby 概述 在远程终端工具中&#xff0c;secureCrt 和 XShell 是两款比较有名的远程工具&#xff0c;但…

shell脚本之例题详解

文章目录 1 检查用户家目录中的test.sh文件是否存在&#xff0c;并且检查是否有执行权限2 提示用户输入100米赛跑的秒数&#xff0c;要求判断秒数大于0且小于等于10秒的进入选拔赛&#xff0c;大于10秒的都淘汰&#xff0c;如果输入其它字符则提示重新输入&#xff1b;进入选拔…

Selenium:集成测试报告

目录 一、分拆后的实现代码 二、创建用于执行所有用例的ALL_HTMLtest.py文件 三、集成测试报告 随着软件不断迭代功能越来越多&#xff0c;对应的测试用例也会呈指数增长。一个实现几十个功能的项目&#xff0c;对应的用例可能有上百个甚至更多&#xff0c;如果全部集成在一…

RocketMQ中单消费者订阅多个Topic,会阻塞消费吗?

RocketMQ 问题 背景是这样&#xff1a; 最近有个项目用MQ做消息流转&#xff0c;在RocketMQ集群模式下&#xff0c;一个消费者实例&#xff0c;订阅了两个Topic A、B。 Topic A&#xff1a;存储的是批量业务消息。 Topic B&#xff1a;存储的是单个业务消息。 有个小伙伴问我…

基于C++的职工管理系统

1、管理系统需求 职工管理系统可以用来管理公司内所有员工的信息 本教程主要利用C++来实现一个基于多态的职工管理系统 公司中职工分为三类:普通员工、经理、老板,显示信息时,需要显示职工编号、职工姓名、职工岗位、以及职责 普通员工职责:完成经理交给的任务 经理职责:完成…

分布式系统概念和设计-分布式文件系统服务体系结构和实践经验

分布式系统概念和设计 文件系统的特点 负责文件的组织&#xff0c;存储&#xff0c;检索&#xff0c;命名&#xff0c;共享和保护 文件包含数据和属性 数据&#xff1a;包含一系列数据项——8比特的字节&#xff0c;读写操作可访问任何一部分数据属性&#xff1a;用一个记录表…

一文详解 SCTP 协议

SCTP(Stream Control Transmission Protocol)流控制传输协议,由 RFC2960 定义。SCTP的设计目的是提供一种可靠的、面向消息的数据传输服务,以便于支持多点通信以及满足传输的可靠性需求。SCTP 目前广泛应用于VoIP、移动通信和云计算等领域。 SCTP 主要特点SCTP 消息结构SCTP …

Android9.0 原生系统SystemUI下拉状态栏和通知栏视图之锁屏通知布局

1.前言 在9.0的系统rom定制化开发中,对于系统原生systemui的锁屏界面的功能也是非常重要的,所以在锁屏页面布局中,也是有通知栏布局的,所以接下来对于息屏亮屏 通知栏布局的相关流程分析,看下亮屏后锁屏页面做了哪些功能 2.原生系统SystemUI下拉状态栏和通知栏视图之锁…

应用层开发想转Android framework开发要从何开始

前言 现如今&#xff0c;由于市面上应用App的更新逐渐变少&#xff0c;很多Android移动应用开发者都开始转型做系统开发&#xff0c;这比开发应用有趣多了&#xff0c;因为你可以探索系统模块的运行原理&#xff0c;从框架层面去了解它。 在应用层&#xff0c;你只需要配置好…

JAVA-异常

文章目录 1.异常的体系1.3异常的分类 2.异常的处理2.2异常的抛出throw2.3异常的捕获2.3.1异常声明throws2.3.2 try-catch捕获并处理2.3.3 finally 2.4 异常的处理流程 3.自定义异常类 1.异常的体系 Throwable&#xff1a;是异常体系的顶层类&#xff0c;其派生出两个重要的子类…

前端框架篇学习--选择命令式还是声明式

命令式与声明式定义 大白话&#xff1a;假期回家了&#xff0c;我想吃老妈的大盘鸡&#xff0c;然后老妈就去采购食材&#xff0c;剁鸡块&#xff0c;卤鸡肉&#xff0c;切土豆&#xff0c;然后爆炒起来&#xff0c;想方设法给我做好吃的大盘鸡。老妈上菜的餐桌&#xff0c;我…

SQL语句学习笔记(对库、表、字段、的操作)

查看mysql的状态 status 启动、停止 mySQL服务 图像界面方法&#xff1a; dos窗口执行&#xff1a;services.msc 控制面板–>管理工具–>服务 命令行方法&#xff1a; 启动&#xff1a; net start mysql80 停止&#xff1a; net stop mysql80 启动与环境变量 添加环境…

UnityShaderBook中消融dissolve详解

消融这个效果算得上游戏开发中用的比较多的一个效果&#xff0c;表现游戏对象消失的时候经常用到&#xff0c;这个效果实现也非常简单&#xff0c;因此在《UnityShader入门精要》中也就短短几句话讲完了&#xff0c;这里我想针对书中的效果详细讲解一下。 Shader源代码&#x…