小编Alt*_*haf的帖子

如何使用webrequest使用Json数组绘制折线图

首先,我对C#和Json很新.

我想在C#GUI中绘制mysql表数据的图形.我制作了一个PHP文件来从mysql数据库表中选择数据并使用json数组回显所选内容echo json_encode(array("result"=>$result))

这是我的PHP:

<?php
define('HOST','*********************');
define('USER','*********************');
define('PASS','*********************');
define('DB','***********************');

if($_SERVER['REQUEST_METHOD']=='GET'){

 $start = $_GET['start'];
 $ending  = $_GET['ending'];
}

$con = mysqli_connect(HOST,USER,PASS,DB);


$sql = "SELECT * FROM table WHERE date_time BETWEEN '$start' and '$ending'" ;
$res = mysqli_query($con,$sql);

$result = array();
while($row = mysqli_fetch_array($res)){
array_push($result,array('id'=>$row[0],'p_pairs'=>$row[1],'temp1'=>$row[2]  ,'temp2'=>$row[3],'temp3'=>$row[4],'temp4'=>$row[5],'temp5'=>$row[6],'avg_current'=>$row[7],'avg_voltage'=>$row[8],'kw'=>$row[9],'kwh'=>$row[10]));
}

echo json_encode(array($result));

mysqli_close($con);

?>
Run Code Online (Sandbox Code Playgroud)

使用链接,我可以清楚地看到日期时间间隙之间的json数组.我想要的是用线图中的date_time绘制温度值(temp1,temp2,..),p对值等的图形.阅读历史数据.

我访问PHP页面时得到的是:

[[{"id":"1","p_pairs":"0000-00-00 00:00:00","temp1":"2","temp2":"100","temp3":"100","temp4":"100","temp5":"100","avg_current":"100","avg_voltage":"300","kw":"300","kwh":"300"},{"id":"2","p_pairs":"0000-00-00 00:00:00","temp1":"45","temp2":"105","temp3":"230","temp4":"100","temp5":"2500","avg_current":"570","avg_voltage":"100","kw":"250","kwh":"1000"},{"id":"3","p_pairs":"2016-01-07 21:10:00","temp1":"45","temp2":"105","temp3":"230","temp4":"100","temp5":"2500","avg_current":"570","avg_voltage":"100","kw":"250","kwh":"1000"},{"id":"4","p_pairs":"2016-01-07 21:10:00","temp1":"45","temp2":"105","temp3":"230","temp4":"100","temp5":"2500","avg_current":"570","avg_voltage":"100","kw":"250","kwh":"1000"}]]
Run Code Online (Sandbox Code Playgroud)

注意:某些日期时间在此处设置为默认值.我只想展示这个数组.正确的一个将是完美的绘制图形.

我可以使用来自C#的Web请求将这些数组放在一个字符串中.使用波纹管代码:

        System.Net.WebClient wc = new System.Net.WebClient();
        byte[] raw = wc.DownloadData("url to php");

        string webData = System.Text.Encoding.UTF8.GetString(raw);
Run Code Online (Sandbox Code Playgroud)

这将是一个很大的帮助如果有人可以帮我在线图中绘制这个作为date_time Vs temp1,temp2或p_pairs,就像在C#GUI中那样...

这对我来说将是一个很大的帮助.提前感谢你.

php c# mysql json

8
推荐指数
1
解决办法
566
查看次数

从单应性分解中找到最合适的旋转和平移

我正在尝试从 Homography 函数中找到旋转和平移。首先我计算相应的特征点并使用findHomography()我计算单应矩阵。然后,使用decomposeHomographyMat(),我得到了四个旋转和平移结果。

我使用的代码如下:

Mat frame_1, frame_2;


frame_1 = imread("img1.jpg", IMREAD_GRAYSCALE);
frame_2 = imread("img2.jpg", IMREAD_GRAYSCALE);

vector<KeyPoint> keypts_1, keypts_2;
Mat desc1, desc2;

Ptr<Feature2D> ORB = ORB::create(100    );
ORB->detectAndCompute(frame_1, noArray(), keypts_1, desc1);
ORB->detectAndCompute(frame_2, noArray(), keypts_2, desc2);

Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-Hamming");
vector<DMatch> matches;
matcher->match(desc1, desc2, matches);

vector<Point2f>leftPts, rightPts;
    for (size_t i = 0; i < matches.size(); i++)
    {
        //queryIdx is the left Image
        leftPts.push_back(keypts_1[matches[i].queryIdx].pt);

        //trainIdx is the right Image
        rightPts.push_back(keypts_2[matches[i].trainIdx].pt);
    }

Mat cameraMatrix = (Mat1d(3, 3) << 706.4034, 0, …
Run Code Online (Sandbox Code Playgroud)

opencv multiview computer-vision homography

2
推荐指数
1
解决办法
3027
查看次数

标签 统计

c# ×1

computer-vision ×1

homography ×1

json ×1

multiview ×1

mysql ×1

opencv ×1

php ×1