Category Archives: Error

OpenCV4 Error: imread(argv[1], CV_LOAD_IMAGE_COLOR);

Imread (argv [1], cv_load_image_color) in opencv4 reports an error
view the imread() function description. The second parameter

enum ImreadModes {
       IMREAD_UNCHANGED            = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation.
       IMREAD_GRAYSCALE            = 0,  //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
       IMREAD_COLOR                = 1,  //!< If set, always convert image to the 3 channel BGR color image.
       IMREAD_ANYDEPTH             = 2,  //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
       IMREAD_ANYCOLOR             = 4,  //!< If set, the image is read in any possible color format.
       IMREAD_LOAD_GDAL            = 8,  //!< If set, use the gdal driver for loading the image.
       IMREAD_REDUCED_GRAYSCALE_2  = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
       IMREAD_REDUCED_COLOR_2      = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
       IMREAD_REDUCED_GRAYSCALE_4  = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
       IMREAD_REDUCED_COLOR_4      = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
       IMREAD_REDUCED_GRAYSCALE_8  = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
       IMREAD_REDUCED_COLOR_8      = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
       IMREAD_IGNORE_ORIENTATION   = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.
     };

Change the second parameter to imread_Grayscale is enough.

The second method:
Add header file:

#include <opencv2/imgcodecs/legacy/constants_c.h>

At this time, the parameter CV_LOAD_IMAGE_Color will not report an error.

[Solved] Wepy build watch Error: ERR! Parse WePY config failed. Are you trying to use

The specific error is
[22:54:56] err! Parse WePY config failed. Are you trying to use WePY 2 to build WePY 1 project?
[22:54:56] ERR! Unexpected type: plugins expect a Array

This is because
the version of wepy used in the current project is 1. X, while the version of wepy on the computer is 2, X

NPM install wepy cli – G command installs version 1. X
NPM install @wepy cli – G command installs version 2. X
the difference is@

Solution:

Locate C:\users\XX\appdata\roaming\NPM\node_Modules folder
delete the @wepy folder, and then execute NPM install wepy cli – G

How to Solve golang test Error: # command-line-arguments [command-line-arguments.test]

Project scenario:

xxx.go xxx_unit test and code of test.go are open. The code is not in gopath and the project root set by idea.

Background:

Gopath:/users/ZYJ/go project root:/users/ZYJ/study/demogo source file:/users/ZYJ/study/demo/go/SRC/xxx_ test.go


Problem Description:

xxx.go xxx_test.go is stored separately   xxx_test.go compilation error

command-line-arguments [command-line-arguments.test]

Cause analysis:

Go test XXX executed by golang IDE_test.go runs as file by default and does not import dependent files. You need to actively import dependencies

Usually: the project is in gopath or project root directory, and the dependency can be found normally


Solution:

go test -v xxxx.go xxxx_test.go

Golang ide multiple selections for quick operation

[Solved] Android Networking error: CLEARTEXT communication to www.xxxxx.xyz not permitted by network security policy

Question

Android networking error: cleartext communication to www.xxxxx.xyz not allowed by network security policy

Question

After targetsdkversion26, for security reasons, Google requires encrypted connections for Android applications, so an error will be reported when using HTTP for network access

Solution:

1. Targetsdkversion dropped below 27

Pre connect unencrypted before targetsdkversion 27

2. Modify the androidmanifest.xml configuration file

Add the following attributes in the application tab

    android:usesCleartextTraffic="true"

How to Solve using stm32f4 to drive PS2 error

Cause

When porting PS2 code for the project, I thought it was a simple thing. I closed it for several hours. The data I read has been incorrect (the data beat is unstable). I decided to give up, but I still decided to step on the pit to the end! So there is this article

Solution direction

Based on the previous experience of pit drainage, the problems may lie in the following places

    1. hardware problem IO port configuration, clock tree configuration and timer configuration. The underlying driver code is not suitable (the widely circulated code is F103 version)

Problem exploration

      1. hardware problem

 

      1. an F103 board was found and driven normally. The problem of PS2 damage and wire open circuit was eliminated. IO port configuration

 

      1. the IO port configured according to the official routine, tested that the output of each IO port is normal, and tried to modify the speed of the IO port, which is useless. The underlying driver code is not adapted to the

 

      1. PS2 driver code. Only the following lines refer to the underlying
#define DI    HAL_GPIO_ReadPin(PS2_DAT_GPIO_Port,PS2_DAT_Pin) 
#define DO_H  HAL_GPIO_WritePin(PS2_CMD_GPIO_Port,PS2_CMD_Pin,GPIO_PIN_SET)     
#define DO_L  HAL_GPIO_WritePin(PS2_CMD_GPIO_Port,PS2_CMD_Pin,GPIO_PIN_RESET)     
#define CS_H  HAL_GPIO_WritePin(PS2_CS_GPIO_Port,PS2_CS_Pin,GPIO_PIN_SET)      
#define CS_L  HAL_GPIO_WritePin(PS2_CS_GPIO_Port,PS2_CS_Pin,GPIO_PIN_RESET)     
#define CLK_H  HAL_GPIO_WritePin(PS2_CLK_GPIO_Port,PS2_CLK_Pin,GPIO_PIN_SET)   
#define CLK_L  HAL_GPIO_WritePin(PS2_CLK_GPIO_Port,PS2_CLK_Pin,GPIO_PIN_RESET)  

Check the macro definition of each IO port to correspond to the IO port on the board. Delay is also used in many places in the source code_ms/delay_US function uses a mature timer library to ensure the accuracy of delay, so this problem is also eliminated
4. Timer configuration
unlike F1, which uses TIM4 as the internal clock, F4 uses tim5, but both are ordinary timers and have no essential difference, so the problem is obviously not here
5. Clock tree configuration
finally, the problem is located here
referring to the official routine, change the master clock frequency from 180mhz to 72mhz. It is normal
in other words, PS2 has high requirements for communication timing. The maximum clock frequency of F4 will accelerate the communication frequency, which may lead to the collapse of some protocols, so the data is unstable.

Prospect

Of course, the optimal solution is not to change the clock frequency of the chip, which will affect the execution rate of other programs. Theoretically, the timing can be restored to normal by adding a certain delay operation to the driver code, but I didn’t do it because of time. I hope interested players can have an in-depth study, and it’s best to share the code. (not found on the Internet at present)

Error in plot.new() : figure margins too large

Error in plot.new() : figure margins too large

Full error:


#Question

Fit the regression model and calculate the dfbetas value of each sample and the optimal dfbetas threshold. Finally, visualize the impact of each sample on each predictive variable;

#fit a regression model
model <- lm(mpg~disp+hp, data=mtcars)

#view model summary
summary(model)

#calculate DFBETAS for each observation in the model
dfbetas <- as.data.frame(dfbetas(model))

#display DFBETAS for each observation
dfbetas

#find number of observations
n <- nrow(mtcars)

#calculate DFBETAS threshold value
thresh <- 2/sqrt(n)

thresh

#specify 2 rows and 1 column in plotting region

#dev.off()
#par(mar = c(1, 1, 1, 1))

par(mfrow=c(2,1))

#plot DFBETAS for disp with threshold lines
plot(dfbetas$disp, type='h')
abline(h = thresh, lty = 2)
abline(h = -thresh, lty = 2)

#plot DFBETAS for hp with threshold lines 
plot(dfbetas$hp, type='h')
abline(h = thresh, lty = 2)
abline(h = -thresh, lty = 2)

#Solution
par(mar = c(1, 1, 1, 1))

#fit a regression model
model <- lm(mpg~disp+hp, data=mtcars)

#view model summary
summary(model)

#calculate DFBETAS for each observation in the model
dfbetas <- as.data.frame(dfbetas(model))

#display DFBETAS for each observation
dfbetas

#find number of observations
n <- nrow(mtcars)

#calculate DFBETAS threshold value
thresh <- 2/sqrt(n)

thresh

#specify 2 rows and 1 column in plotting region

#dev.off()
par(mar = c(1, 1, 1, 1))

par(mfrow=c(2,1))

#plot DFBETAS for disp with threshold lines
plot(dfbetas$disp, type='h')
abline(h = thresh, lty = 2)
abline(h = -thresh, lty = 2)

#plot DFBETAS for hp with threshold lines 
plot(dfbetas$hp, type='h')
abline(h = thresh, lty = 2)
abline(h = -thresh, lty = 2)


Full Error Message:
> par(mfrow=c(2,1))
>
> #plot DFBETAS for disp with threshold lines
> plot(dfbetas$disp, type=’h’)
Error in plot.new() : figure margins too large
> abline(h = thresh, lty = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
plot.new has not been called yet
> abline(h = -thresh, lty = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
plot.new has not been called yet
>
> #plot DFBETAS for hp with threshold lines
> plot(dfbetas$hp, type=’h’)
Error in plot.new() : figure margins too large
> abline(h = thresh, lty = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
plot.new has not been called yet
> abline(h = -thresh, lty = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
plot.new has not been called yet

Error in *** : subscript out of bounds [How to Solve]

Error in *** : subscript out of bounds

Full error:


Question:

The data is out of bounds. Except for others, who knows where it is? Do you ask memory? Who do you ask?

#make this example reproducible
set.seed(0)

#create matrix with 10 rows and 3 columns
x = matrix(data = sample.int(100, 30), nrow = 10, ncol = 3)

#print matrix
print(x)

#attempt to display 11th row of matrix
x[11, ]

#attempt to display 4th column of matrix
x[, 4]

#attempt to display value in 11th row and 4th column
x[11, 4]

Solution:

#

#display number of rows and columns in matrix
dim(x)

#

#display 10th row of matrix
x[10, ]

#display number of columns in matrix
ncol(x)

#display 3rd column of matrix
x[, 3]

#display value in 10th row and 3rd column of matrix
x[10, 3]

Full error Messages:
>
> #attempt to display 11th row of matrix
> x[11, ]
Error in x[11, ] : subscript out of bounds
>
> #attempt to display 4th column of matrix
> x[, 4]
Error in x[, 4] : subscript out of bounds
>
> #attempt to display value in 11th row and 4th column
> x[11, 4]
Error in x[11, 4] : subscript out of bounds
>

Shiro Error: Configuration error: No realms have been configured!

solution

Check if the ini configuration file is written in a standard way

correct demonstration:

error demonstration:

exception information

2021-10-05 17:12:26.609 [main] WARN  org.apache.shiro.authc.AbstractAuthenticator - Authentication failed for token submission [org.apache.shiro.authc.UsernamePasswordToken - ans, rememberMe=false].  Possible unexpected error?(Typical or expected login exceptions should extend from AuthenticationException).
java.lang.IllegalStateException: Configuration error:  No realms have been configured!  One or more realms must be present to execute an authentication attempt.
	at org.apache.shiro.authc.pam.ModularRealmAuthenticator.assertRealmsConfigured(ModularRealmAuthenticator.java:161)
	at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:264)
	at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198)
	at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106)
	at org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:275)
	at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:260)
	at com.yas.MyApplication.test(MyApplication.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Preprocessor Symbols setting error: error: redefinition of enumerator

The error information is as follows:

../../../../GD32F10x_ Firmware_ Library/CMSIS/GD/GD32F10x/Include\gd32f10x.h(168): error: redefinition of enumerator ‘USBD_ HP_ CAN0_ TX_ IRQn’

../../../../GD32F10x_ Firmware_ Library/CMSIS/GD/GD32F10x/Include\gd32f10x.h(169): error: redefinition of enumerator ‘USBD_ LP_ CAN0_ RX0_ IRQn’

Cause of problem:

Preprocessor symbols should be set to gd32f10x_ MD, but it is set to gd32f10x_ HD

Analysis description:

Preprocessor symbols

Preprocessor symbols means preprocessing symbols, which is equivalent to macro definitions. When we use the gd32 firmware library, because the firmware library contains the definitions of the whole series of GD microcontrollers. At this time, the define box can be used as a global macro definition, that is, select which part of the definitions and resources in the firmware library I want to adopt.

USE_STDPERIPH_DRIVER

It literally means “use standard peripheral driver”. Adding “use_stdperiph_driver” to the C/C + + predefined allows “use standard peripheral driver”. As for the added “gd32f10x_hd”, it can also be explained in the file “gd32f10x. H” through function search as described above. In fact, it also switches some definitions of corresponding hardware.

GD32F10X_HD&GD32F10X_MD

In fact, it defines the capacity of the chip

/* define GD32F10x */
#if !defined (GD32F10X_MD) && !defined (GD32F10X_HD) && !defined (GD32F10X_XD) && !defined (GD32F10X_CL)
  /* #define GD32F10X_MD */     /*!< GD32F10X_MD: GD32 Medium density devices */
  /* #define GD32F10X_HD */     /*!< GD32F10X_HD: GD32 High density Value Line devices */  
  /* #define GD32F10X_XD */     /*!< GD32F10X_XD: GD32 Extra density devices */
  /* #define GD32F10X_CL */     /*!< GD32F10X_CL: GD32 Connectivity line devices */  
#endif /* define GD32F10x */