Skip to content

Instantly share code, notes, and snippets.

@Temptationx
Temptationx / 6 omxplayer
Created February 16, 2018 06:13
6 omxplayer
nohup omxplayer --win 0,0,640,480 -n -1 SampleVideo_640x360_30mb.mp4 &
nohup omxplayer --win 640,0,1280,480 -n -1 SampleVideo_640x360_30mb.mp4 &
nohup omxplayer --win 1280,0,1920,480 -n -1 SampleVideo_640x360_30mb.mp4 &
nohup omxplayer --win 0,480,640,960 -n -1 SampleVideo_640x360_30mb.mp4 &
nohup omxplayer --win 640,480,1280,960 -n -1 SampleVideo_640x360_30mb.mp4 &
@Temptationx
Temptationx / UTF-8与GBK(或GB2312)编码转换.cpp
Created December 6, 2017 00:13
UTF-8与GBK(或GB2312)编码转换
string GBKToUTF8(const char* strGBK)
{
int len = MultiByteToWideChar(CP_ACP, 0, strGBK, -1, NULL, 0);
wchar_t* wstr = new wchar_t[len+1];
memset(wstr, 0, len+1);
MultiByteToWideChar(CP_ACP, 0, strGBK, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len+1];
memset(str, 0, len+1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
@Temptationx
Temptationx / gist:0e107e446918cc7f3ed9bb221c32dc02
Created December 2, 2017 12:54
wstring与string相互转换
#include <string>
#include <locale.h>
// 需包含locale、string头文件、使用setlocale函数。
std::wstring StringToWstring(const std::string str)
{// string转wstring
unsigned len = str.size() * 2;// 预留字节数
setlocale(LC_CTYPE, ""); //必须调用此函数
wchar_t *p = new wchar_t[len];// 申请一段内存存放转换后的字符串
mbstowcs(p,str.c_str(),len);// 转换
std::string s(std::istreambuf_iterator<char>(Poco::FileInputStream(string("t.txt"))), {});
@Temptationx
Temptationx / 1080p
Created November 25, 2017 06:49
ubuntu强制分辨率
#!/bin/bash
xrandr --newmode "1920x1080_60_001" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
xrandr --addmode VGA-1 "1920x1080_60_001"
xrandr --output VGA-1 --mode "1920x1080_60_001"
@Temptationx
Temptationx / channel_mixer.c++
Created February 9, 2015 21:27
channel_mixer
struct ChannelMixerParameter
{
int output_channel;
double r;
double g;
double b;
};
void channel_mixer(const cv::Mat &src, cv::Mat &m, const ChannelMixerParameter &param)
{
@Temptationx
Temptationx / socket_client.c++
Created February 9, 2015 21:22
socket_client
void main()
{
WSADATA wsaData;
auto success = WSAStartup(MAKEWORD(2, 2), &wsaData);
// ERROR_CHECK
SOCKET m_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// ERROR_CHECK
sockaddr_in addr = { 0 };
addr.sin_addr.S_un.S_addr = inet_addr("192.168.1.118");
addr.sin_family = AF_INET;
@Temptationx
Temptationx / match.cpp
Created February 9, 2015 21:19
opencv match template
void match(Mat &a, Mat &b)
{
Mat r;
matchTemplate(a, b, r, CV_TM_SQDIFF_NORMED);
double minVal; double maxVal; Point minLoc; Point maxLoc;
Point matchLoc;
minMaxLoc(r, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
@Temptationx
Temptationx / disconnect.c++
Last active March 14, 2019 19:20
C++ lambda Qt disconnect
auto conn = std::make_shared<QMetaObject::Connection>();
*conn = QObject::connect(obj, &Object::signal, this, [this, conn]() {
disconnect(*conn);
});
@Temptationx
Temptationx / UTF8ToUTF16.cpp
Last active August 29, 2015 14:08
utf-8, gbk, utf-16 转换
wstring UTF8ToUTF16(const char *strUTF8)
{
int len = MultiByteToWideChar(CP_UTF8, 0, strUTF8, -1, NULL, 0);
wchar_t* wszGBK = new wchar_t[len + 1];
memset(wszGBK, 0, len * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, strUTF8, -1, wszGBK, len);
wstring ret(wszGBK);
if (wszGBK) {
delete[] wszGBK;
}