26 Eylül 2018 Çarşamba

18 Eylül 2018 Salı

QtConcurrent Kullanımı

QtConcurrent  mutex,semaphore gibi primitive yapıları kullanmadan yüksek seviyeli uygulama yazmamıza olanak saglar 

QTConcurrent ile yazılmış uygulamalar uygun olan şekilde core otomatik ayarlanır 


.proya  QT += concurrent eklenir

// main. cpp 
#include <    QCoreApplication             >
#include <    QtConcurrent/QtConcurrent    >
#include <    QThread                      >
#ifndef QT_NO_CONCURRENT

void myRunFunction(QString name)
{
    for(int i=0;i<10 ;i++)
    {
        qDebug()<<  name << " from   "  << QThread::currentThread();
    }
}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QFuture<  void  > t1 = QtConcurrent::run(myRunFunction ,QString("A"));
    QFuture<  void  > t2 = QtConcurrent::run(myRunFunction ,QString("B"));
    QFuture<  void  > t3 = QtConcurrent::run(myRunFunction ,QString("C"));

    t1.waitForFinished();
    t2.waitForFinished();
    t3.waitForFinished();


    return a.exec();
}

#else
#include 

int main(int argc, char *argv[])
{
    QApplication app(argc,argv);
    QString text("QtConcurrent is not yet supported on this platform");
    QLabel *label =new QLabel(text);
    qDebug()<
    app.exec();
}
#endif

Share:

arduino ile potansiyometre ve buzzer calıstırma


void setup()
{
  pinMode(A2,INPUT);
  pinMode(A3,OUTPUT);
  Serial.begin(9600);

}

void loop()
{
  int konum=analogRead(A2);
  konum=map(konum,0,1023,0,255);  // 1024 aralıgında ise 0 ,255 aralıgına düşürür
  Serial.println(konum);
  delay(50);
  analogWrite(A3,konum);
}




// BUTTON İLE LED YAKMA


void setup()
{
  pinMode(LED,OUTPUT);
  pinMode(BUTON,INPUT);

}

void loop()
{
  if(digitalRead(BUTON)==HIGH)
  {
    digitalWrite(LED,HIGH);
  }
  else
  {
    digitalWrite(LED,LOW);
  }
}

Share:

Mutex with QT

*mutex kullanımı
//myhtread.h
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include < QtCore >    

class MyThread:public QThread
{
public:
    MyThread();
    void run();
    QString name;
    bool Stop;
};

#endif // MYTHREAD_H




//main.cpp
#include < QCoreApplication >
#include "mythread.h"
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    MyThread m1;
    m1.name="first thread";

    MyThread m2;
    m2.name="second thread";

    MyThread m3;
    m3.name="third thread";

    m1.start(QThread::HighestPriority);
  //  m2.start(QThread::LowestPriority);
  //  m3.start();
    m1.Stop =true;
    
    return a.exec();
}



// thread.cp
#include "mythread.h"
#include < QtCore >  // UNUTULMAMALI CORE KULLANILACAK 
#include< QDebug >

#include < QThread >
MyThread::MyThread()
{

}

void MyThread::run()
{

    for(int i=0;i<10;i++)
    {
        QMutex mutex;
        if(this->Stop)
        {
            break;
        }
        mutex.unlock();
        this->sleep(1);
        qDebug() << "Runnning"<<name <<"   : "<< i;

    }
    
}

Share:

Create Threate with QT

*Thread olusturma
1)ilk olarak bir proje olusturulur
2)yeni bir class eklenir
3)yeni olusturulan classa #include   eklenir  ve class ile :public QThread miras alınır 
4)public olarak run() fonksiyonu yaratılır
5)main cpp de ise #include    ve #include "mythread.h" ile class ana uygulamaya eklenir 
6)class source file kısmında(thread.cpp de )  run fonksiyonunda yapılmasını istedigimiz işleri yazarız
void MyThread::run()
{

    for(int i=0;i<10 i="" p="">    {
        qDebug() << "Runnning"<
    }
}
6) istedigimiz kadar threadi artık olusturup start ile baslatırız
    MyThread m1;
    m1.name="first thread";
m1.start();
Share:

4 Eylül 2018 Salı

HOW TO FFMPEG

*open cmd and go /ffmpeg/bin


1)video information //ffmpeg -i video.mp4
2)convert video //ffmpeg -i video.mp4 video.avi 
3)if you want preserve quality : 
ffmpeg -i video.mp4 -qscale 0 video.avi
4) if you want to see supported formats 
// ffmpeg -formats
5)change resolution // 
ffmpeg -i input.mp4 -s 1280x720 -c:a copy output.mp4
6)compres audio files 
//ffmpeg -i input.mp3 -ab 128 output.mp3
7) Removing audio stream from a media file
ffmpeg -i a.mp4 -an no_voice.mp4
8)Removing from video from media file 
ffmpeg -i a.mp4 -vn no_video.mp4
9)extracting image from video file 
ffmpeg -i a.mp4 -r 1 -f image2 image-%2d.png
10) crop video
ffmpeg -i a.mp4 -croptop 100 -cropbottom 100
 -cropleft 300 -cropright 300 cropvideo.mp4
11)specific crop (minute/second)
ffmpeg -i a.mp4  -t 50 specific_crop.mp4  
(first 50 seconds)
12) set aspect ratio to video
ffmpeg -i a.mp4 -aspect 16:9 aspect.mp4
13)view video 
ffplay a.mp4
14)change speed video 
ffmpeg -i inputvideo.mp4 
-vf "setpts=0.5*PTS" outputvideo.mp4
Share: