Adding data to GraphViewSeries - android-graphview

I have a working app using Graphview in Android Studio. API 18 using com.jjoe64:graphview:3.1.3
When I try to add data that has (x(I+1) b- x(I)) < 0 the app crashes with "Unfortunately. app has stopped.
Is this a bug or are negative deltaX not allowed?
Here is a sample
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] {
new GraphViewData(1, 40)
, new GraphViewData(2, 12)
, new GraphViewData(3, 7)
, new GraphViewData(2, 8) //note negative delta x
, new GraphViewData(4, 10)
});

It's not allowed - that's how it's documented to work:
values - the values must be in the correct order! x-value has to be ASC.

Related

I have trouble getting depth information from the DEPTH16 format with the Camera2 API using ToF on P30 pro

I am currently testing options for depth measurement with the smartphone and wanted to create a depth image initially for testing. I am using the Camera2Basic example as a basis for this. (https://github.com/android/camera-samples/tree/main/Camera2Basic) Using Depth16 I get a relatively sharp "depth image" back. But the millimetres are not correct. They are in a range around from 3600mm to 5000mm for an object like a wall that is about 500mm or 800mm away from the camera.
But what puzzles me the most is that the image does not transmit any information in the dark. If Android is really targeting the ToF sensor for DEPTH16, it shouldn't be affected in the dark, should it? Or do I have to use AR-Core or Huawei's HMS core to get a real ToF image?
I am using a Huawei P30 Pro and the code for extracting the depth information looks like this. And yes performance wise it is bullshit but it is only for testing purposes:)
private Map<String, PixelData> parseDepth16IntoDistanceMap(Image image) {
Map<String, PixelData> map = new HashMap();
Image.Plane plane = image.getPlanes()[0];
// using asShortBuffer() like in the documentation leads to a wrong format (for me) but does not help getting better values
ByteBuffer depthBuffer = plane.getBuffer().order(ByteOrder.nativeOrder());
int stride = plane.getRowStride();
int offset = 0;
int i = 0;
for (short y = 0; y < image.getHeight(); y++) {
for (short x = 0; x < image.getWidth(); x++) {
short depthSample = depthBuffer.getShort( (y / 2) * stride + x);
short depthSampleShort = (short) depthSample;
short depthRange = (short) (depthSampleShort & 0x1FFF);
short depthConfidence = (short) ((depthSampleShort >> 13) & 0x7);
float depthPercentage = depthConfidence == 0 ? 1.f : (depthConfidence - 1) / 7.f;
maxz = depthRange;
sum = sum + depthRange;
numPoints++;
listOfRanges.add((float) depthRange);
if (depthRange < minz && depthRange > 0) {
minz = depthRange;
}
map.put(x + "_" + y, new PixelData(x, y, depthRange, depthPercentage));
i++;
}
}
return map;
}
In any case, it would help a lot to know if you can get the data this way at all, so I know if I'm already doing something fundamentally wrong. Otherwise I will change to one of the ar systems. Either way, many thanks for your efforts
If you want to extract a depth map where you can see the distance to an object you might use ARCORE Depth API.
https://developers.google.com/ar/develop/java/depth/overview
Or you can follow the codelab where shows you how to get the data in millimeters.
https://codelabs.developers.google.com/codelabs/arcore-depth#0

Anylogic Variable Not Updating

I an using a discrete event simulator in AnyLogic. I am having an issue with some code which updates a variable in my simulation. I store both the datetime at which the agent leaves the source block and the datetime at which it enters the sink block. I am trying to record the number of "rule breaks" for all agents. The rule break is defined below (two ways to break):
1) If the agent is received before a certain time (called SDC) and the agent is not completed by 5pm the same day, then the agent has broken the rule
2) If the agent is not completed by the next day at a certain time (called NDC), then the agent has broken the rule
I record a zero or a one for each agent if they break either rule in the variable called RuleBreak. However, in my simulation runs, the variable does not update at all. I hope I am just missing something small. Would appreciate any help! (code below)
Calendar received = Calendar.getInstance();
received.setTime(ReceivedDate);
Calendar completion = Calendar.getInstance();
completion.setTime(Completion);
Calendar SD_at_5 = Calendar.getInstance();
SD_at_5.setTime(ReceivedDate);
SD_at_5.set(Calendar.HOUR_OF_DAY,17);
SD_at_5.set(Calendar.MINUTE, 0);
SD_at_5.set(Calendar.SECOND, 0);
Calendar Tomorrow_at_NDC = Calendar.getInstance();
Tomorrow_at_NDC.setTime(ReceivedDate);
if(Tomorrow_at_NDC.get(Calendar.DAY_OF_WEEK) == 6)
Tomorrow_at_NDC.add(Calendar.DATE, 3);
else
Tomorrow_at_NDC.add(Calendar.DATE, 1);
Tomorrow_at_NDC.add(Calendar.DATE, 1);
Tomorrow_at_NDC.set(Calendar.HOUR_OF_DAY,NDC);
Tomorrow_at_NDC.set(Calendar.MINUTE, 0);
Tomorrow_at_NDC.set(Calendar.SECOND, 0);
int Either_rule_break = 0;
double time_diff_SDC = differenceInCalendarUnits(TimeUnits.SECOND,completion.getTime(),SD_at_5.getTime());
double time_diff_NDC = differenceInCalendarUnits(TimeUnits.SECOND,completion.getTime(),Tomorrow_at_NDC.getTime());
if((received.get(Calendar.HOUR_OF_DAY) < SDC) && (time_diff_SDC <= 0))
Either_rule_break = Either_rule_break + 1;
else
Either_rule_break = Either_rule_break + 0;
if((received.get(Calendar.HOUR_OF_DAY) >= SDC) && (time_diff_NDC <= 0))
Either_rule_break = Either_rule_break + 1;
else
Either_rule_break = Either_rule_break + 0;
if((Either_rule_break >= 1))
RuleBreak = RuleBreak + 1;
else
RuleBreak = RuleBreak + 0;
You haven't really explained where this code is used and what it receives. I assume the code is in a function, called in the sink's on-enter action, where ReceivedDate and Completion are Date instances stored per agent (source exit time and sink entry time, as dates, captured via AnyLogic's date() function).
And looks like your SDC hour-of-day is stored in SDC and your NDC hour-of-day in NDC (with RuleBreak being a variable in Main or similar storing the total number of rule-breaks).
Your calculations look OK except that the Tomorrow_at_NDC Calendar calculation seems wrong: you add 1 day twice (if not Saturday) or 3 days plus 1 day (if Saturday; in a Java Calendar, day-of-week 1 is Monday).
(Your Java is also very 'inefficient' with unnecessary extra local variables and performing logic when you don't need to; e.g., no point doing all the calendar preparation and check for your type 1 rule-break if the receive time is after the SDC hour.)
But are you sure there are any rule-breaks; how have you set up your model to ensure that there are (to test it)? Plus is RuleBreak definitely a variable outside of the agents that flow through your DES (i.e., in Main or similar)? Plus are Completion and ReceivedDate definitely stored per agent so, for example, if your function was called checkForRuleBreaks you would be doing something like the below in your sink on-exit action:
agent.Completion = date(); // Agent received date set earlier in Source action
checkForRuleBreaks(agent.ReceivedDate, agent.Completion);
(In fact, you don't need to store the completion date in the agent at all since that will always be the current sim-date inside your function and so you can just calculate it there.)

Implement OpenCV for Image Marker detecting

i have set up an app using OpenCV framework, to detect an image marker with the camera, and then react if the image on the screen matches the marker.
So far i have gotten quite a way by following:
https://medium.com/#dwayneforde/image-recognition-on-ios-with-swift-and-opencv-b5cf0667b79
And have also used his code, to implement the image-matching-function. Everything is set up, and i should be ready to go... but... The app crashes when it try to run the application.
The problem lies where i check for matches. I use this code as instructed in the tutorial:
- (void)processImage:(cv::Mat &)img {
cv::Mat gimg;
// Convert incoming img to greyscale to match template
cv::cvtColor(img, gimg, CV_BGR2GRAY);
// Use check for matches with a certain threshold to help with scaling and angles
cv::Mat res(img.rows-gtpl.rows+1, gtpl.cols-gtpl.cols+1, CV_32FC1);
cv::matchTemplate(gimg, gtpl, res, CV_TM_CCOEFF_NORMED);
cv::threshold(res, res, 0.5, 1., CV_THRESH_TOZERO);
double minval, maxval, threshold = 0.9;
cv::Point minloc, maxloc;
cv::minMaxLoc(res, &minval, &maxval, &minloc, &maxloc);
// If it's a good enough match
if (maxval >= threshold)
{
// Draw a rectangle for confirmation
cv::rectangle(img, maxloc, cv::Point(maxloc.x + gtpl.cols, maxloc.y + gtpl.rows), CV_RGB(0,255,0), 2);
cv::floodFill(res, maxloc, cv::Scalar(0), 0, cv::Scalar(.1), cv::Scalar(1.));
// Call our delegates callback method
[delegate matchedItem];
}
}
The problem seems to be with the line:
cv::matchTemplate(gimg, gtpl, res, CV_TM_CCOEFF_NORMED);
And i get this error-message:
OpenCV(3.4.1) Error: Assertion failed (corrsize.height <= img.rows + templ.rows - 1 && corrsize.width <= img.cols + templ.cols - 1) in crossCorr, file /Volumes/build-storage/build/master_iOS-mac/opencv/modules/imgproc/src/templmatch.cpp, line 589
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(3.4.1) /Volumes/build-storage/build/master_iOS-mac/opencv/modules/imgproc/src/templmatch.cpp:589: error: (-215) corrsize.height <= img.rows + templ.rows - 1 && corrsize.width <= img.cols + templ.cols - 1 in function crossCorr
Can anyone see what i am doing wrong?

QlikSense - Set Analysis - Handling complexities - Arithmetic, Fields, Variables, Variables within variables, Greater than etc

I am somewhat new to QlikSense, but am getting a hang of it. Set Analysis is probably my weak spot and no matter how much I read, I tend to forget everything within hours. Plus, the guides don't do a great job explaining how to handle more complex/'tricky' situations (aka Level II or III complexity) than what they deem complex (aka Level 1 complexity) .
I went through this, this and this, still no dice. The only thing left for me to do is to bang my head to the wall and see if something shakes up.
The actual file is pretty big and proprietary, so can't post it here... so I would appreciate if you can give me an idea and point me in the right direction.
GOAL:
I have an expression that works, but I need it in the form of set analysis. Simple, right?
BACKGROUND:
//IN LOAD SCRIPT - set some default values
SET dMinSOS = 20000;
SET dMaxSUSPD = 225;
SET dSUR = 1;
SET dSOR = 0.3;
//IN LOAD SCRIPT - generate some custom inputs so user can select a value
FOR i = 1 to 20
LET counter = i*5000;
LOAD * INLINE [
Min. SOS
$(counter)
];
NEXT i
FOR i = 0 to 9
LET counter = i/10;
LOAD * INLINE [
SOR
$(counter)
];
NEXT i
FOR i = 1 to 30
LET counter = i/10;
LOAD * INLINE [
SUR
$(counter)
];
NEXT i
FOR i = 1 to 15
LET counter = i*25;
LOAD * INLINE [
Max. SUSPD
$(counter)
];
NEXT i
//IN LOAD SCRIPT - if user selects a value from above, then get the max because they can select multiple; otherwise use default values
SET vMinSOS = "IF(ISNULL([Min. SOS]), $(dMinSOS), MAX([Min. SOS]))";
SET vMaxSUSPD = "IF(ISNULL([Max. SUSPD]), $(dMaxSUSPD), MAX([Max. SUSPD]))";
SET vSUR = "IF(ISNULL([SUR]), $(dSUR), MAX([SUR]))";
SET vSOR = "IF(ISNULL([SOR]), $(dSOR), MAX([SOR]))";
//EXPRESSION - works! - [Size], [Heads], [SPD] are direct fields in a table, the return value of 1 or 0 is strictly for reference
=IF(
[Size] >= $(vMinSOS) AND
[Size] - ((([Heads] * IF([SPD] >= $(vMaxSUSPD), $(vMaxSUSPD), [SPD])) / $(vSUR)) + ([Size] * $(vSOR))) >= 0,
1, 0)
//SET ANALYSIS - this needs fixing - i.e. replicate 2nd condition in expression above - Show just the results where both the conditions above are true
=SUM({<
[Size]={">=$(=$(vMinSOS))"},
[Size]={">= #### What goes here? #### "},
>}[Size])
Open to recommendations on better ways of solving this.
=SUM({
"=[Size] >= $(vMinSOS) AND [Size] - ((([Heads] * IF([SPD] >= $(vMaxSUSPD), $(vMaxSUSPD), [SPD])) / $(vSUR)) + ([Size] * $(vSOR))) >= 0"
}>} [Size] )

The color depth 1 is not supported

I am using iTextSharp version 5.5.2.0 and when trying to load the attached pdf sample 058780-02.pdf I get an exception in the ImageRenderInfo.GetImage() method the "PdfImageObject" is not returned and with a message saying "The color depth 1 is not supported".
Any suggestions?
Thanks,
Abedellatif
i fixed it, modify the iTextSharp source code PdfImageObject class FindColorspace method at 222 line add
if (PdfName.CALGRAY.Equals(tyca) || PdfName.DEVICEGRAY.Equals(tyca)) {
stride = (width * bpc + 7) / 8;
pngColorType = 0;
}