I am building an android and ios applicaion using xamarin that should detects the object that I click on in an image . I have succeeded in detecting if a specific object is in the image or not using https://portal.clarifai.com , by training some models and predict the probability of their presence in the image .
Now I am trying to detect the position of this object (to predict after that what is the object that I am clicking on )
can anyone help me please ?
var client = new ClarifaiClient(my-api-key);
var response = await client.Predict<Concept>(my-concept-id,
new ClarifaiFileImage(ReadFully((file.GetStream())))).ExecuteAsync();
foreach (var concept in response.Get().Data)
{
s += concept.Name + " : " + concept.Value + "\n";
}
You can't get the position of the object inside a picture with Clarifai, but you can with Microsoft's Custom Vision AI.
As you can see in the documentation, it gives you the exact coordinates for you to do that.
I'm working on coding a bot that will retrieve an image based on search parameters. When the bot returns the message after the command, I want the bot to alert the user that sent the command with a ping. (the notification of a message using the "#" symbol in discord).
Here's what I've got so far:
await Context.Channel.SendMessageAsync("#" + Context.Message.Author + "\n" + imageNode.Attributes["src"].Value);
I'm able to correctly grab the author of the command and it sends as it should--
Output in channel:
However, it's not actually sent as a tag, just plain text.
Is there a way to actually ding the user with a notification?
Yes, using User.Mention.
await Context.Channel.SendMessageAsync(Context.Message.Author.Mention + "\n" + imageNode.Attributes["src"].Value);
You can also just put their id in between <#>. For example, "Hello <#1234>"
One of my favorite things about C# 6 is that you can also use String Interpolation. Very useful in Discord.Net!
var id = Context.Message.Author.Id;
await Context.Channel.SendMessageAsync($"<#{id}> \n {imageNode.Attributes["src"].Value}";
I'm using the GMap control in C#, in a Windows Form application.
I made an app that puts in a map some coordinates. When I use it, from my pc, it works perfectly.
When I try to run the app on other PCs, the coordinates are not given.
Check the comments below in my code.
GeoCoderStatusCode status;
//Here I search the address and the city
PointLatLng? punt = GMapProviders.GoogleMap.GetPoint(punti[i].Address+ ", " + punti[i].City, out status);
//At this I point I check if I received the data
if (status == GeoCoderStatusCode.G_GEO_SUCCESS)
{
double la = punt.Value.Lat;
double lo = punt.Value.Lng;
marker = new GMarkerGoogle(new PointLatLng(la, lo), GMarkerGoogleType.green_dot);
punti[i].Latitudine = la;
punti[i].Longitudine = lo;
}
//If the data is not received...
else
{
//I use some default data (that I get from a txt) based on the city
marker = new GMarkerGoogle(new PointLatLng(lat, lng), GMarkerGoogleType.green_dot);
}
marker.ToolTipText = punti[i].Name+ "\r\n\r\n" + punti[i].Address+ " - " + punti[i].City;
marker.ToolTip = new GMap.NET.WindowsForms.ToolTips.GMapRoundedToolTip(marker);
You understand that if the data are not received I will build a map with lots of markers in the same point.
I repeat: if I use the app from my PC, the markers are put in the right position on the map. The problem occurs only when the app runs on other PCs.
I tried also changing the GMapProvider, but the problem is still there.
What am I doing wrong?
Thanks in advance,
Emmanuele
Google Maps API for Work client IDs are restricted to URLs specifically authorized. If you try to use your client ID at a URL that has not been authorized, you will receive an error message.
Reference
Your app is authorized from your PC's IP only, so using your key to make requests from other machines results in the error you've received.
Instead of invoking the api from clients, you are expected to restrict it to a single authorized server, and then extend your own web service to clients.
I am creating an ical event dynamically in my web application and when someone cancel the appointment on the application we are generating a delete ical event *.ics file to their email to remove the event in their calendar.
Creating is working perfectly but when we try to delete the appointment we created it doesn't remove it from the calendar
Creating Ical event code :
string[] contents = {
"BEGIN:VCALENDAR",
"VERSION:2.0",
"PRODID:-//dev.com//iCal//EN",
"X-WR-CALNAME:development",
"X-WR-RELCALID:928C8448-048A-4aa2-BE27-A920773AF3DC",
"X-FUNAMBOL-ALLDAY:0",
"METHOD:REQUEST",
"BEGIN:VEVENT",
"UID:" + Args.EventUID,
"SEQUENCE:1",
"DTSTART:" + Args.EventStartTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
"DTEND:" + Args.EventEndTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
"LOCATION: " + Args.EventLocation,
"ORGANIZER: test#outlook.com",
"DESCRIPTION;ENCODING=ESCAPED-CHAR:" + Args.EventName,
"SUMMARY:" + Args.EventDescription,
"STATUS:CONFIRMED",
"TRANSP:OPAQUE",
"PRIORITY:" + Args.EventPriority.ToString(),
"END:VEVENT",
"END:VCALENDAR"
};
Creating an event works perfectly on iphone/android/outlook
Delete event part:
string[] contents = {
"BEGIN:VCALENDAR",
"VERSION:2.0",
"METHOD:CANCEL",
"X-WR-CALNAME:development",
"X-WR-RELCALID:928C8448-048A-4aa2-BE27-A920773AF3DC",
"PRODID:-//dev.com//iCal//EN",
"X-FUNAMBOL-ALLDAY:0",
"BEGIN:VEVENT",
"UID:" + Args.EventUID,
"SEQUENCE:2",
"DTSTART:" + Args.EventStartTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
"DTEND:" + Args.EventEndTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
"LOCATION: " + Args.EventLocation,
"DESCRIPTION;ENCODING=ESCAPED-CHAR:" + Args.EventName,
"SUMMARY:" + Args.EventDescription,
"ORGANIZER: test#outlook.com",
"PRIORITY:" + Args.EventPriority.ToString(),
"STATUS:CANCELLED",
"TRANSP:OPAQUE",
"END:VEVENT",
"END:VCALENDAR"
};
When I click this file generated to remove the event that is already created it doesn't remove the event and sometimes it duplicates the event.
The ical UID on creating and delete are the same.
First, scrutinise the UID. I know you say they're the same, but check ! Whitespace? Case?
Next, put PRODID on the second line, straight after BEGIN (Ignore the validators when they tell you to put VERSION on the second line.) This sounds trivial, the field is not even used, but Outlook in particular is ridiculously picky. Copy a working example. Test and tell me if I'm wrong.
Next, SEQUENCE is indexed from 0. Clients may interpret SEQUENCE:1 as an update, and wonder where is the original invitation.
Next, check the structure and mime type headers of your emails. I got best results by sending a simple single part email with Content-type: text/calendar; method="[REQUEST/CANCEL]" in the MIME header.
Still not working? Try adding an ATTENDEE element, with participation required, rsvp true etc, repeating the email address of the recipient.
Still problems? Use the online Icalendar validators to check your output, but also copy exactly a working example. Send yourself an invitation, then cancel it, from gmail and/or outlook. Everything is important - the structure of the message, the order of the fields in the Icalendar, the MIME headers of the email. Sending to GMail lets you see exactly what is received, via the gmail show original option.
I notice you are doing nothing for wrapping. Ical lines are limited to 75 characters, not much, and overflowing lines must start with a space. A validator will quickly tell you.
The difference may also be whether the calendar app has 'subscribed' or 'imported' the ics file? Subscribed events should update, imported ones generally may not as the user could have changed them - may vary between calendar apps.
Try using PUBLISH as METHOD and 0 as SEQUENCE for submitting and 1 as SEQUENCE for erasing.
Example of submitting:
string[] contents = {
"BEGIN:VCALENDAR",
"VERSION:2.0",
"PRODID:-//site.domain//iCal//EN",
"METHOD:PUBLISH",
"BEGIN:VEVENT",
"UID:" + Args.EventUID,
"SEQUENCE:0",
"DTSTART:" + Args.EventStartTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
"DTEND:" + Args.EventEndTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
"SUMMARY:" + Args.EventDescription,
"STATUS:CONFIRMED",
"END:VEVENT",
"END:VCALENDAR"
};
Example of erasing:
string[] contents = {
"BEGIN:VCALENDAR",
"VERSION:2.0",
"PRODID:-//site.domain//iCal//EN",
"METHOD:CANCEL",
"BEGIN:VEVENT",
"UID:" + Args.EventUID,
"SEQUENCE:1",
"DTSTART:" + Args.EventStartTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
"DTEND:" + Args.EventEndTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
"SUMMARY:" + Args.EventDescription,
"STATUS:CANCELLED",
"END:VEVENT",
"END:VCALENDAR"
};
Video can be restricted, if it's video is set to be not available for users region, if it is private or if video owner has set limitations on where it can be displayed. I don't want to display them.
Query what I have at the moment:
Feed<Video> videoFeed = request.GetStandardFeed(
"http://gdata.youtube.com/feeds/api/videos?v=2" +
"&format=5&iv_load_policy=3&q=" + this.textBox1.Text);
Initially I build a list of type item, that acts as a datasource. Precondition here could also fix my problem.
foreach (Video entry in feed.Entries)
dsList.Add(new item { ID = entry.VideoId, TITLE = entry.Title });
How do I use the Youtube API to check if a video viewing is restricted?
edit:
I assumed, I can use:
foreach (Video entry in feed.Entries)
if (entry.Status == null)
dsList.Add(new item { ID = entry.VideoId, TITLE = entry.Title });
But there are at least 2 problems with that:
Youtube api can maximally return 50 items over 10 pages per query. Maximum of 500 items - that is more, then gets used in average case. But if restricted content has higher ordering precedence (example: major label music videos), then 99% or more results can get thrown away.
Filter works for most cases, but it does not seem to work for (EMI : Coldplay - Every Teardrop Is A Waterfall (Official)), that is listed under top rated videos feed. I don't want to display:
The YouTube API includes an attribute called accessControl. This includes fields that tell you whether embedding and playback on mobile devices and televisions is allowed.
See this page for more:
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_yt:accessControl
I would take a look at the API documentation on custom parameters.
Specifically the restriction and region parameters.
Very simple solution
Public Function IsVideoExits(VideoID As String) As Boolean
Try
If Image.FromStream(New MemoryStream(WC.DownloadData("http://i3.ytimg.com/vi/" + VideoID + "/hqdefault.jpg"))).Height > 0 Then Return True
Catch ex As Exception
Return False
End Try
End Function
You could find if the video is exits/Allowed to view in this way in 6 code lines even without the API
That's a VB code. Think U could convert to your own