C/C++/C#
文章平均质量分 57
学习笔记
1226km
这个作者很懒,什么都没留下…
展开
-
C++:Windows平台下利用LibTorch调用PyTorch模型
文章目录环境Libtorch下载Pytorch将.pth转为.pt文件python环境下的预测输出结果:rose新建pt模型生成文件输出结果:roseC++调用pytorch模型新建空项目pt_alex项目属性配置修改配置管理器属性>VC++目录>包含目录属性>VC++目录>库目录属性>链接器>输入>附加依赖项注意CUDA下的情况属性>C/C++项目下新建test.cpp输出结果:roseC# Demo新建C++空项目,封装DLL源码项目属性点击生成解决方案,原创 2022-03-03 15:29:11 · 5505 阅读 · 12 评论 -
C++:VS包含目录、继承值修改
VS重装后修改VC++包含目录、继承值以及附加依赖项等主要是为了修改默认使用的opencv版本(1)进入目录: C:\Users\xxx\AppData\Local\Microsoft\MSBuild\v4.0(2)使用文本编辑器打开文件 Microsoft.Cpp.Win32.user.props 及 Microsoft.Cpp.x64.user.props(3)修改 或 中间内容。(4)重新打开VS,问题解决。...原创 2022-03-01 17:47:27 · 3855 阅读 · 0 评论 -
C#:利用button控件本地上传图片并显示
界面代码// Form1.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace XXX{ p原创 2022-02-28 16:41:13 · 1696 阅读 · 0 评论 -
C#:登陆注册功能
注册//界面//Form1.Designer.cs private void InitializeComponent() { this.tb_username = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.L原创 2020-07-23 14:40:20 · 1196 阅读 · 0 评论 -
C#:调用dll时的char*参数与string参数
//生成dll的C++函数//参数为char* float camDetect(char * imageData)//C#调用dll中的该函数 [DllImport("CamDet.dll", CallingConvention = CallingConvention.Cdecl)] public extern static float camDetect(string imageData); //loadFile为string类型 float p = camDetect(loadF原创 2020-07-10 09:40:30 · 1149 阅读 · 0 评论 -
C#:浮点数float与字符串string相互转换
string str = Convert.ToString(float); float f = float.Parse(str);原创 2020-05-29 11:49:17 · 15355 阅读 · 0 评论 -
C#:button界面跳转
//Program.csstatic void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1 Register = new Form1(); Register.ShowDialog(); if (Registe原创 2020-05-28 08:21:45 · 2916 阅读 · 0 评论 -
C#:文本框textbox焦点事件
Form.Designer.cs // // tb_password1 // this.tb_password1.Location = new System.Drawing.Point(304, 149); this.tb_password1.Margin = new System.Windows.Forms.Padding(4); this.tb_password1.Name原创 2020-05-28 08:19:13 · 2112 阅读 · 0 评论 -
C#:读写txt文件
参考Form.cs//按钮事件private void button1_Click(object sender, EventArgs e) { string username = tb_username.Text; //获取用户名 auth(username); //验证 //获取txt文件 string f = "auth\\" + tb_username.Text + ".txt";原创 2020-05-25 09:28:37 · 716 阅读 · 0 评论 -
C语言:菜鸟教程-结构体
菜鸟教程-C结构体C 数组允许定义可存储相同类型数据项的变量,结构是 C 编程中另一种用户自定义的可用的数据类型,它允许您存储不同类型的数据项。结构用于表示一条记录,假设您想要跟踪图书馆中书本的动态,您可能需要跟踪每本书的下列属性:TitleAuthorSubjectBook ID定义结构为了定义结构,您必须使用 struct 语句。struct 语句定义了一个包含多个成员的新的数据类型,struct 语句的格式如下:struct tag { member-list转载 2020-06-10 11:36:37 · 1341 阅读 · 0 评论 -
C++:按行读取json文件中的字符串转化为浮点数数组
//json文件示例[0.2237, 0.188, 0.1803, 0.7784, 0.5635, 0.2954, 0.216, 0.0135, 0.2526][0.2217, 0.1349, 0.1716, 0.7674, 0.5554, 0.2609, 0.14, 0.1373, 0.2009][0.1841, 0.1568, 0.1539, 0.8558, 0.5318, 0.2989, 0.1566, 0.1362, 0.2666][0.2626, 0.1328, 0.1539, 0.74,原创 2020-06-08 12:44:50 · 1224 阅读 · 0 评论 -
C语言:菜鸟教程经典100例题(51-80)
C语言经典100例注:以下答案与原文不完全相同实例1-50实例51 - 与&// Created by www.runoob.com on 15/11/9.// Copyright © 2015年 菜鸟教程. All rights reserved.//#include <stdio.h>int main(){ int a, b; a = 077; b = a & 3; printf("a & b(decimal) 为 %d \n", b)原创 2020-06-05 10:09:27 · 1737 阅读 · 4 评论 -
C语言:菜鸟教程经典100例题(1-50)
C语言经典100例注:以下答案与原文不完全相同实例1有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?#include <stdio.h>int main(void){ int i, j, k; int n = 0; for (i = 1; i < 5; i++) { for (j = 1; j < 5; j++) { for (k = 1; k < 5; k++) { if (i != j &原创 2020-06-03 14:21:23 · 10223 阅读 · 5 评论 -
余弦相似度:通过计算两个向量的夹角余弦值来评估他们的相似度
余弦值的范围在[-1,1]之间,值越趋近于1,代表两个向量的方向越接近;越趋近于-1,他们的方向越相反;接近于0,表示两个向量近乎于正交。float comparator(const float* comp1, const float* comp2) // 传入两个数组{ float similarity; float sum = 0; float sum1 = 0, sum2 = 0; for (int i = 0; i < 4; i++) // 已知每个数组各含4个元素 .原创 2020-06-03 09:46:04 · 2497 阅读 · 0 评论 -
C语言:键盘监听(按键/按下与释放时间)
#include <windows.h>#include <stdio.h>#include<math.h>#include<string.h>HANDLE hStdin;DWORD fdwSaveOldMode;VOID ErrorExit(LPSTR);int KeyEventProc(KEY_EVENT_RECORD);//VOID MouseEventProc(MOUSE_EVENT_RECORD);//VOID ResizeEv原创 2020-05-13 15:42:07 · 4913 阅读 · 0 评论 -
C语言:封装DLL并用C#调用
新建C++win32空项目//main.h 创建头文件#pragma once//#ifdef _MSC_VER && __cplusplus//#define SDK_API extern "C" __declspec(dllexport)//#else//#define SDK_API extern "C"//#endif__declspec(dllexport) void key(); //main.c 要封装的源文件#include "main.h"原创 2020-05-11 10:57:55 · 1120 阅读 · 0 评论 -
C语言:字符与字符串
字符转成字符串char ch = 'a';char str[2];str[0] = ch;str[1] = 0;原创 2020-05-09 14:26:53 · 209 阅读 · 0 评论 -
C/C++:读写txt文件
读写txt文件#include<fstream>std::string filename = username + ".txt"; //文件名std::ofstream writefile(filename); writefile << password << "\n"; //写入password内容std::ifstream readFile(...原创 2020-05-07 09:41:02 · 818 阅读 · 0 评论 -
C++:警告C4018-有符号/无符号不匹配
https://blog.csdn.net/wangyang20170901/article/details/80061472 for (int i = 0; i < people.size(); i++) 修改: for (unsigned int i = 0; i < people.size(); i++)原创 2020-05-06 12:23:25 · 185 阅读 · 0 评论 -
C++:str与int相互转换
int→str:int = to_string(str);str→int:C++中将string类型转化为int类型#include <iostream>#include <string.h>#include <stdlib.h>using namespace std;int main(){ string a="11",b="22"; co...原创 2020-05-06 12:06:33 · 801 阅读 · 0 评论 -
C++:cout与std::cout
1、未使用命名空间,则每次都要进行说明:std::cout << 1;std::cout << 2;std::cout << 3;2、提前使用命名空间,则可以直接使用cout:using namespace std;cout << 1;cout << 2;cout << 3;...原创 2020-05-06 08:27:58 · 595 阅读 · 0 评论 -
C++:获取按下键值及调用python获取当前微秒级时间戳
调用python步骤参考:https://blog.csdn.net/nanguabing007/article/details/89394541原创 2020-05-01 23:07:24 · 196 阅读 · 0 评论 -
C++:获取当前按键键值及时间(1970至今经过的秒数)
#include<conio.h>#include<iostream>#include<ctime>using namespace std;int gettime(){ time_t now = time(0); return now;}int main(){ int ch; while(1) { if(_kbhit()) /...原创 2020-04-30 14:37:20 · 1043 阅读 · 0 评论 -
C++:登录注册功能
codeview在源代码的基础上进行了修改:#include <fstream>#include <iostream>#include <limits>#include <string>template <typename T>T get_input(const std::string &strQuery);s...原创 2020-05-07 10:17:15 · 2899 阅读 · 1 评论 -
C语言:scanf()输入字符串
参考scanf函数输入字符串,C语言scanf函数输入字符串详解代码#include<stdio.h>char* getusername(){ printf("Please enter a username:"); char username[64]; //error: char* username; scanf("%s",&username); printf("Username: %s \n", username); return username;}原创 2020-05-09 11:00:13 · 2848 阅读 · 0 评论