Harigami
ログイン
Harigamiは、ログイン不要のコード共有サービスです。コードの投稿後に発行されるURLでコードを共有できます。
PythonやRubyなど一部の言語は、投稿後にオンラインで実行することもできます。
誰でも無料で使えて、広告もありません。コードレビューやスニペットの代わりに使ってみてください。


詳細設定
+
anonymous タイトルなし
Python
56757598
  • 0
  • 0
anonymous タイトルなし
Python
Fffffffff
  • 0
  • 0
anonymous タイトルなし
Python
import cv2
print(cv2)
import numpy as np
'''
# カメラのキャプチャを開始 --- (*1)
cam = cv2.VideoCapture(0)
while True:
    # 画像を取得 --- (*2)
    _, img = cam.read()
    # ウィンドウに画像を表示 --- (*3)
    cv2.imshow('PUSH ENTER KEY', img)
    # Enterキーが押されたら終了する
    if cv2.waitKey(1) == 13: break
# 後始末
cam.release()
cv2.destroyAllWindows()
'''

def find_rect_of_target_color(image):
  hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV_FULL)
  h = hsv[:, :, 0]
  s = hsv[:, :, 1]
  mask = np.zeros(h.shape, dtype=np.uint8)
  mask[((h < 20) | (h > 200)) & (s > 128)] = 255
  contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
  rects = []
  for contour in contours:
    approx = cv2.convexHull(contour)
    rect = cv2.boundingRect(approx)
    rects.append(np.array(rect))
  return rects


if __name__ == "__main__":
  capture = cv2.VideoCapture()
  while cv2.waitKey(30) < 0:
    _, frame = capture.read()
    rects = find_rect_of_target_color(frame)
    for rect in rects:
      cv2.rectangle(frame, tuple(rect[0:2]), tuple(rect[0:2] + rect[2:4]), (0, 0, 255), thickness=2)
    cv2.imshow('red', frame)
  capture.release()
  cv2.destroyAllWindows()
  • 0
  • 1
anonymous タイトルなし
C
#include<stdio.h>
#define num 10

void mergesort(int ary[], int left, int right){

    int i, j, k, mid;
    int temp[num];

    if(left < right){

        mid = (left + right)/2;

        mergesort(ary, left, mid);
        mergesort(ary, mid + 1, right);

        for(i = left; i <= mid; i++){
            temp[i] = ary[i];
        }

        for(j = mid + 1; j <= right; j++){
            temp[right - (j - (mid + 1))] = ary[j];
        }

        i = left, j = right;

        for(k = left; k <= right; k++){
            if(temp[i] < temp[j]){
                ary[k] = temp[i];
                i++;
            }
            else{
                ary[k] = temp[j];
                j--;
            }
        }
    }
}

void merge(int ary1[], int ary2[], int ary3[]){
    int i, j, k;
    i = j = k = 0;

    for(; k < num * 2; k++){
        if(ary1[i] < ary2[j]){
            ary3[k] = ary1[i];
            i++;
        }
        else{
            ary3[k] = ary2[j];
            j++;
        }
    }
}

int main(void){
    int ary1[num], ary2[num], ary3[num * 2];

    for(int i = 0; i < num; i++){
        scanf("%d",&ary1[i]);
    }

    for(int i = 0; i < num; i++){
        scanf("%d",&ary2[i]);
    }

    mergesort(ary1,0,num - 1);

    mergesort(ary2,0,num - 1);

    for(int i = 0; i < num; i++){
        printf("%d,", ary1[i]);
    }
    printf("\n");

    for(int i = 0; i < num; i++){
        printf("%d,", ary2[i]);
    }
    printf("\n");

    merge(ary1, ary2, ary3);

    for(int i = 0; i < num * 2; i++){
        printf("%d, ",ary3[i]);
    }

    printf("\n");
}
  • 0
  • 1
anonymous タイトルなし
C
#include<stdio.h>
#define num 10

void mergesort(int ary[], int left, int right){

    int i, j, k, mid;
    int temp[num];

    if(left < right){

        mid = (left + right)/2;

        mergesort(ary, left, mid);
        mergesort(ary, mid + 1, right);

        for(i = left; i <= mid; i++){
            temp[i] = ary[i];
        }

        for(j = mid + 1; j <= right; j++){
            temp[right - (j - (mid + 1))] = ary[j];
        }

        i = left, j = right;

        for(k = left; k <= right; k++){
            if(temp[i] < temp[j]){
                ary[k] = temp[i];
                i++;
            }
            else{
                ary[k] = temp[j];
                j--;
            }
        }
    }
}

void merge(int ary1[], int ary2[], int ary3[]){
    int i, j, k;
    i = j = k = 0;

    for(; k < num * 2; k++){
        if(ary1[i] < ary2[j]){
            ary3[k] = ary1[i];
            i++;
        }
        else{
            ary3[k] = ary2[j];
            j++;
        }
    }
}

int main(void){
    int ary1[num], ary2[num], ary3[num * 2];

    for(int i = 0; i < num; i++){
        scanf("%d",&ary1[i]);
    }

    for(int i = 0; i < num; i++){
        scanf("%d",&ary2[i]);
    }

    mergesort(ary1,0,num - 1);

    mergesort(ary2,0,num - 1);

    for(int i = 0; i < num; i++){
        printf("%d,", ary1[i]);
    }
    printf("\n");

    for(int i = 0; i < num; i++){
        printf("%d,", ary2[i]);
    }
    printf("\n");

    merge(ary1, ary2, ary3);

    for(int i = 0; i < num * 2; i++){
        printf("%d, ",ary3[i]);
    }

    printf("\n");
}
  • 0
  • 0
ガンマ@駆け出しエンジニア MTF MovingAvg2Line Cross
Python
//@version=4
strategy("MTF MovingAvg2Line Cross", overlay=true)
ES = input(title="MA1の選択", defval="EMA", options=["EMA", "SMA"])
ES2 = input(title="MA2の選択", defval="EMA", options=["EMA", "SMA"])
len = input(title='時間軸', type=input.resolution, defval="60")
res = input(defval=true, title="チェック=MTF表示")
res2 = res ? len : timeframe.period
fastLength = input(9)
slowLength = input(18)
price = close
fsma=sma(price, fastLength)
fema=ema(price, fastLength)
fast = ES == "EMA" ? fsma : fema
ssma=sma(price, slowLength)
sema=ema(price, slowLength)
slow = ES2 == "EMA" ? ssma : sema
mafast = security(syminfo.tickerid, res2,fast)
maslow = security(syminfo.tickerid, res2,slow)
if (crossover(mafast, maslow))
    strategy.entry("MA2CrossLE", strategy.long, comment="MA2CrossLE")
if (crossunder(mafast, maslow))
    strategy.entry("MA2CrossSE", strategy.short, comment="MA2CrossSE")
plot(mafast, color=color.lime)
plot(maslow, color=color.red)
  • 0
  • 1
ガンマ@駆け出しエンジニア MTF Keltner Channel Strategy
Python
//@version=4
strategy("MTF Keltner Channel Strategy", overlay=true)
source = close
len = input(title=' 期間', type=input.resolution, defval="60")
res = input(defval=true, title="チェック=MTF表示")
res2 = res ? len : timeframe.period
useTrueRange = input(true)
length = input(20, minval=1)
mult = input(1.0)
ma = sma(source, length)
range = useTrueRange ? tr : high - low
rangema = sma(range, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
basis = avg(upper, lower)
ures = security(syminfo.tickerid, res2, upper)
lres = security(syminfo.tickerid, res2, lower)
bres = security(syminfo.tickerid, res2, basis)
crossUpper = crossover(source, ures)
crossLower = crossunder(source, lres)
bprice = 0.0
bprice := crossUpper ? high+syminfo.mintick : nz(bprice[1])
sprice = 0.0
sprice := crossLower ? low -syminfo.mintick : nz(sprice[1]) 
crossBcond = false
crossBcond := crossUpper ? true 
 : na(crossBcond[1]) ? false : crossBcond[1]
crossScond = false
crossScond := crossLower ? true 
 : na(crossScond[1]) ? false : crossScond[1]
cancelBcond = crossBcond and (source < ma or high >= bprice )
cancelScond = crossScond and (source > ma or low <= sprice )
if (cancelBcond)
    strategy.cancel("KltChLE")
if (crossUpper)
    strategy.entry("KltChLE", strategy.long, stop=bprice, comment="KltChLE")
if (cancelScond)
    strategy.cancel("KltChSE")
if (crossLower)
    strategy.entry("KltChSE", strategy.short, stop=sprice, comment="KltChSE")
plot(ures, color=color.aqua)
plot(lres, color=color.aqua)
plot(bres, color=color.orange, style=plot.style_cross)
  • 0
  • 0
Retired K@PCK タイトルなし
C++
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================
  • 0
  • 1
anonymous タイトルなし
Python
A=[1,2,3]
L=[[0]*3]*3

for i in range(len(A)):
    for n in range(len(A)):
        L[i][n]=A[i]*A[n]
print(L)

#output [[3, 6, 9], [3, 6, 9], [3, 6, 9]] 
#こうなってほしい→[[1, 2, 3], [2, 4, 6], [3, 6, 9]] 
  • 0
  • 1
anonymous タイトルなし
Python
When you order 1000 backlinks with this service you get 1000 unique domains, Only receive 1 backlinks from each domain. All domains come with DA above 15-20 and with actual page high PA values. Simple yet very effective service to improve your linkbase and SEO metrics. 
 
Order this great service from here today: 
https://monkeydigital.co/product/unique-domains-backlinks/ 
 
Multiple offers available 
 
thanks and regards 
Mike 
monkeydigital.co@gmail.com
  • 0
  • 0