Beispiel #1
0
 public JpegImage(byte[] data, JpegImage.ImageType imageType, string imageUrl)
 {
     Debugger.printToDebug("Creating Jpeg");
     rawDataGetSet = data;
     type          = imageType;
     //urlGetSet = imageUrl;
 }
Beispiel #2
0
    private string getUrlStringForImageType(JpegImage.ImageType type)
    {
        string       latestImagePageUrl = getUrlForLatestImagePage(type);
        HtmlWeb      web = new HtmlWeb();
        HtmlDocument doc = new HtmlDocument();

        doc = web.Load(latestImagePageUrl);
        int    count  = 0;
        string result = "";

        foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
        {
            HtmlAttribute att = link.Attributes["href"];

            if (att.Value.Contains("sdcard?path"))
            {
                result = "http://192.168.143.141" + att.Value;
                count += 1;
            }
        }

        if (count == 1)
        {
            imageManager.debugMessage = result;
            return(result);
        }
        if (count == 0)
        {
            return("url not found");
        }
        return("multiple url found");
    }
Beispiel #3
0
    private string getUrlForLatestImagePage(JpegImage.ImageType type)
    {
        switch (type)
        {
        case JpegImage.ImageType.RGB:
            return("http://192.168.143.141/last_img?lnk=li0&camera=1");

        case JpegImage.ImageType.NIR:
            return("http://192.168.143.141/last_img?lnk=li0&camera=2");

        default:
            return("");
        }
    }
Beispiel #4
0
    public void FetchLatestImage(JpegImage.ImageType type)
    {
        HttpClient client = new HttpClient();
        string     url    = getUrlStringForImageType(type);

        client.Get(new Uri(url), HttpCompletionOption.AllResponseContent, async(r) =>
        {
            imageManager.debugMessage = "Fetching Image";
            byte[] data = r.ReadAsByteArray();
            imageManager.debugMessage = "data read";
            imageManager.debugMessage = "data size is " + r.PercentageComplete.ToString() + type.ToString();
            //imageManager.debugMessage = "status code is: " + r.StatusCode.ToString();
            //imageManager.debugMessage = "isSuccessStatusCode: " + r.IsSuccessStatusCode.ToString();
            JpegImage jpeg = new JpegImage(data, type, url);
            //imageManager.debugMessage = "jpeg created. Data size is " + data.Length.ToString();
            imageManager.updateLatestImage(jpeg);
            //imageManager.debugMessage = type.ToString() + "Image Fetched";
            //imageManager.debugMessage = data[2000].ToString();
        });
    }