Skip to content

Instantly share code, notes, and snippets.

#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for the iPhone.
# Creates a set of universal libraries that can be used on an iPhone and in the
Syntax: x264 [options] -o outfile infile [widthxheight]
Infile can be raw YUV 4:2:0 (in which case resolution is required),
or YUV4MPEG 4:2:0 (*.y4m),
or Avisynth if compiled with support (no).
or libav* formats if compiled with lavf support (no) or ffms support (no).
Outfile type is selected by filename:
.264 -> Raw bytestream
.mkv -> Matroska
.flv -> Flash Video
@pengdu
pengdu / avcapture.m
Created October 18, 2019 10:21 — forked from bellbind/avcapture.m
[objective-c][macosx]capturing image from webcam
// capture image from webcam(e.g. face time)
// for OSX 10.9 (use AVFoundation API instead of deprecated QTKit)
// clang -fobjc-arc -Wall -Wextra -pedantic avcapture.m
// -framework Cocoa -framework AVFoundation -framework CoreMedia
// -framework QuartzCore -o avcapture
#import <AVFoundation/AVFoundation.h>
#import <AppKit/AppKit.h>
@interface Capture : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate>

以下是使用C++实现双边网格滤波算法的示例代码,不依赖于任何第三方库:

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

// 双边滤波器
以下是一种较为复杂的自动白平衡算法,称为“灰度世界假设”(Gray World Assumption):
1. 将图像转换为LAB颜色空间。
2. 对于每个像素,计算其在LAB颜色空间中的L, a, b值。
3. 计算图像的平均L, a, b值。
4. 将平均值的a, b值分别设置为0,保持平均值的L值不变。

以下是使用Lambda表达式将C++的list转换为map的示例代码:

#include <iostream>
#include <list>
#include <map>
#include <string>

using namespace std;

可以使用C++标准库中的vector来实现一个简单的2维卷积函数。以下是一个示例代码:

#include <iostream>
#include <vector>

using namespace std;

// 二维卷积函数
vector<vector<int>> conv2d(const vector<vector<int>>& img, const vector<vector<int>>& kernel)
@pengdu
pengdu / chatgpt两个有序数组的中值.md
Last active August 8, 2023 09:15
chatgpt两个有序数组的中值

在C++中,可以使用二分查找的思想来找到两个有序数组的中值。具体步骤如下:

  1. 确保数组nums1是较短的数组,如果不是,则交换nums1和nums2。
  2. 定义两个变量,m和n,分别表示数组nums1和nums2的长度。
  3. 定义两个指针,left和right,分别指向数组nums1和nums2的划分位置。
  4. 初始化left为0,right为m。
  5. 进行二分查找,直到找到合适的划分位置。
    • 令i = (left + right) / 2,j = (m + n + 1) / 2 - i。
    • 如果nums1[i - 1] > nums2[j],则说明划分位置过大,需要将right左移。
    • 如果nums2[j - 1] > nums1[i],则说明划分位置过小,需要将left右移。
@pengdu
pengdu / 递归的方式来反转链表.md
Created August 8, 2023 09:18
chatgpt递归的方式来反转链表

在C++中,可以使用递归的方式来反转链表。具体步骤如下:

  1. 定义一个递归函数reverseList,该函数接收一个指向链表头节点的指针head作为参数,并返回反转后的链表头节点的指针。
  2. 在递归函数中,首先判断特殊情况,即如果链表为空或只有一个节点,则直接返回head
  3. 否则,递归调用reverseList函数来反转剩余的链表,并将返回的反转后的链表头节点的指针保存在变量newHead中。
  4. 将当前节点的下一个节点的next指针指向当前节点,即将当前节点的下一个节点指向当前节点,实现反转。
  5. 将当前节点的next指针置空,即将当前节点的下一个节点置空,防止形成环。
  6. 返回newHead作为反转后的链表头节点的指针。

下面是使用C++实现的代码:

@pengdu
pengdu / 接雨水.md
Created August 8, 2023 09:25
chatgpt接雨水

题目描述: 给定一个非负整数数组 height 表示一系列柱子的高度,每个柱子的宽度为 1。计算下雨后,能够在这些柱子之间存储多少雨水。

例子:

输入:height = [0,1,0,2,1,0,1,3,2,1,2,1]
输出:6
解释:如下图所示,灰色区域表示可以存储雨水的地方,可以存储的雨水量为 6 个单位。

   |