This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int majorityElement(vector<int>& nums) { | |
unordered_map<int, int> counter; | |
for (auto num : nums) { | |
if (counter.count(num)) | |
counter[num] += 1; | |
else | |
counter[num] = 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct TreeNode { | |
int val; | |
TreeNode *left; | |
TreeNode *right; | |
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} | |
}; | |
class Codec { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <opencv2/dnn.hpp> | |
#include <opencv2/imgproc.hpp> | |
#include <opencv2/highgui.hpp> | |
#include <opencv2/core/utils/trace.hpp> | |
using namespace cv; | |
using namespace cv::dnn; | |
#include <fstream> | |
#include <iostream> | |
#include <cstdlib> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
This simple script generates the high/low ranked image list from the AVA dataset. | |
It also copies/resizes the source images to a specified folder. | |
This script is assumed to be placed in AVA_ROOT with a folder name 'images', which contains all the source images. | |
Make sure you alter the hard-coded path before using this script. | |
''' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
A simple script to download the images specified in the AVA dataset from dpchallenge. | |
This script is assumed to be placed in AVA_ROOT which contains a folder named 'images'. | |
''' | |
import os | |
import urllib2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <iostream> | |
#include <opencv2/opencv.hpp> | |
using namespace cv; | |
int main(int argc, const char * argv[]) { | |
Mat img = imread("lillestromfisheye.jpg"); | |
// assume the source image is square, and its width has even number of pixels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <boost/filesystem.hpp> | |
#include <boost/algorithm/string.hpp> | |
using namespace boost::filesystem; | |
using std::endl; | |
using std::cout; | |
using std::cerr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <opencv2/opencv.hpp> | |
using namespace std; | |
using namespace cv; | |
int main(int argc, char *argv[]) { | |
Mat m = Mat::ones(5,5, CV_8UC1); | |
cout << m << endl << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================================================================== | |
// Description : Use libcurl to get a remote image file and render by OpenCV | |
// Based on the example from http://curl.haxx.se/libcurl/c/getinmemory.html | |
//================================================================================== | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <curl/curl.h> | |
#include <opencv2/opencv.hpp> |