Front Facing Camera Issue in IPhone 5S IOS 7 - iphone
I have problem on IPhone 5S with front camera output, the same session resolution like rear camera. (AVCaptureSessionPreset352x288) and kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange setting for kCVPixelBufferPixelFormatTypeKey.
I found some discussion on apple forum about exact issue, here is the link: https://discussions.apple.com/message/23079639#23079639
What is the problem?
Please Help.
Good output, rear-facing camera.
Printing description of imageBuffer:
<CVPixelBuffer 0xd5e2f30 width=352 height=288 pixelFormat=420v iosurface=0xd80e724 planes=2>
<Plane 0 width=352 height=288 bytesPerRow=352>
<Plane 1 width=176 height=144 bytesPerRow=352>
<attributes=<CFBasicHash 0xd5c3710 [0x3bf18ad0]>{type = immutable dict, count = 1,
entries =>
1 : <CFString 0x3bf971b4 [0x3bf18ad0]>{contents = "PixelFormatDescription"} = <CFBasicHash 0xb9fce0 [0x3bf18ad0]>{type = immutable dict, count = 7,
entries =>
0 : <CFString 0x3bf97164 [0x3bf18ad0]>{contents = "IOSurfaceCoreAnimationCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
2 : <CFString 0x3bf97194 [0x3bf18ad0]>{contents = "OpenGLESCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
3 : <CFString 0x3bf972c4 [0x3bf18ad0]>{contents = "ContainsAlpha"} = <CFBoolean 0x3bf18e88 [0x3bf18ad0]>{value = false}
5 : <CFString 0x3bf97184 [0x3bf18ad0]>{contents = "IOSurfaceOpenGLESFBOCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
7 : <CFString 0x3bf972d4 [0x3bf18ad0]>{contents = "Planes"} = <CFArray 0xb24830 [0x3bf18ad0]>{type = mutable-small, count = 2, values = (
0 : <CFBasicHash 0xb99420 [0x3bf18ad0]>{type = mutable dict, count = 3,
entries =>
0 : <CFString 0x3bf973b4 [0x3bf18ad0]>{contents = "FillExtendedPixelsCallback"} = <CFData 0xba06a0 [0x3bf18ad0]>{length = 12, capacity = 12, bytes = 0x00000000917cbb3100000000}
1 : <CFString 0x3bf97334 [0x3bf18ad0]>{contents = "BlackBlock"} = <CFData 0xb9deb0 [0x3bf18ad0]>{length = 1, capacity = 1, bytes = 0x10}
2 : <CFString 0x3bf97324 [0x3bf18ad0]>{contents = "BitsPerBlock"} = <CFNumber 0xb277e0 [0x3bf18ad0]>{value = +8, type = kCFNumberSInt32Type}
}
1 : <CFBasicHash 0xba0e50 [0x3bf18ad0]>{type = mutable dict, count = 5,
entries =>
0 : <CFString 0x3bf97334 [0x3bf18ad0]>{contents = "BlackBlock"} = <CFData 0xb9c550 [0x3bf18ad0]>{length = 2, capacity = 2, bytes = 0x8080}
2 : <CFString 0x3bf97344 [0x3bf18ad0]>{contents = "HorizontalSubsampling"} = <CFNumber 0xc0f720 [0x3bf18ad0]>{value = +2, type = kCFNumberSInt32Type}
4 : <CFString 0x3bf97324 [0x3bf18ad0]>{contents = "BitsPerBlock"} = <CFNumber 0xba0e80 [0x3bf18ad0]>{value = +16, type = kCFNumberSInt32Type}
5 : <CFString 0x3bf973b4 [0x3bf18ad0]>{contents = "FillExtendedPixelsCallback"} = <CFData 0xba16d0 [0x3bf18ad0]>{length = 12, capacity = 12, bytes = 0x00000000817bbb3100000000}
6 : <CFString 0x3bf97354 [0x3bf18ad0]>{contents = "VerticalSubsampling"} = <CFNumber 0xc0f720 [0x3bf18ad0]>{value = +2, type = kCFNumberSInt32Type}
}
)}
8 : <CFString 0x3bf97294 [0x3bf18ad0]>{contents = "PixelFormat"} = <CFNumber 0xb7acf0 [0x3bf18ad0]>{value = +875704438, type = kCFNumberSInt32Type}
12 : <CFString 0x3bf97174 [0x3bf18ad0]>{contents = "IOSurfaceOpenGLESTextureCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
}
}
propagatedAttachments=<CFBasicHash 0x126e2130 [0x3bf18ad0]>{type = mutable dict, count = 4,
entries =>
1 : <CFString 0x3bf70edc [0x3bf18ad0]>{contents = "MetadataDictionary"} = <CFBasicHash 0xd5da1a0 [0x3bf18ad0]>{type = mutable dict, count = 7,
entries =>
0 : <CFString 0x3bf70f4c [0x3bf18ad0]>{contents = "SNR"} = <CFNumber 0xd5da1d0 [0x3bf18ad0]>{value = +33.11550123401803347178, type = kCFNumberFloat64Type}
2 : <CFString 0x3bf70ddc [0x3bf18ad0]>{contents = "sensorDGain"} = <CFNumber 0xd58def0 [0x3bf18ad0]>{value = +256, type = kCFNumberSInt32Type}
3 : <CFString 0x3bf70f3c [0x3bf18ad0]>{contents = "SensorID"} = <CFNumber 0x126f7b40 [0x3bf18ad0]>{value = +356, type = kCFNumberSInt32Type}
6 : <CFString 0x3bf7054c [0x3bf18ad0]>{contents = "ExposureTime"} = <CFNumber 0xd5d83d0 [0x3bf18ad0]>{value = +0.03332500000000000046, type = kCFNumberFloat64Type}
7 : <CFString 0x3bf70dec [0x3bf18ad0]>{contents = "ispDGain"} = <CFNumber 0xd54d620 [0x3bf18ad0]>{value = +273, type = kCFNumberSInt32Type}
11 : <CFString 0x3bf7017c [0x3bf18ad0]>{contents = "AGC"} = <CFNumber 0xd5e21f0 [0x3bf18ad0]>{value = +780, type = kCFNumberSInt32Type}
12 : <CFString 0x3bf7114c [0x3bf18ad0]>{contents = "AEAverage"} = <CFNumber 0xd5e27a0 [0x3bf18ad0]>{value = +126, type = kCFNumberSInt32Type}
}
3 : <CFString 0x3bf96f54 [0x3bf18ad0]>{contents = "CVImageBufferYCbCrMatrix"} = <CFString 0xd5c34b0 [0x3bf18ad0]>{contents = "ITU_R_601_4"}
5 : <CFString 0x3bf96f94 [0x3bf18ad0]>{contents = "CVImageBufferColorPrimaries"} = <CFString 0x126bced0 [0x3bf18ad0]>{contents = "ITU_R_709_2"}
6 : <CFString 0x3bf96fd4 [0x3bf18ad0]>{contents = "CVImageBufferTransferFunction"} = <CFString 0xd58dfa0 [0x3bf18ad0]>{contents = "ITU_R_709_2"}
}
nonPropagatedAttachments=<CFBasicHash 0x126e2100 [0x3bf18ad0]>{type = mutable dict, count = 0,
entries =>
}
>
Bad output, front-facing camera.
Printing description of imageBuffer:
<CVPixelBuffer 0x12638980 width=352 height=288 pixelFormat=420v iosurface=0xd80e724 planes=2>
<Plane 0 width=352 height=288 bytesPerRow=384>
<Plane 1 width=176 height=144 bytesPerRow=384>
<attributes=<CFBasicHash 0x12638bb0 [0x3bf18ad0]>{type = immutable dict, count = 1,
entries =>
1 : <CFString 0x3bf971b4 [0x3bf18ad0]>{contents = "PixelFormatDescription"} = <CFBasicHash 0xb9fce0 [0x3bf18ad0]>{type = immutable dict, count = 7,
entries =>
0 : <CFString 0x3bf97164 [0x3bf18ad0]>{contents = "IOSurfaceCoreAnimationCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
2 : <CFString 0x3bf97194 [0x3bf18ad0]>{contents = "OpenGLESCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
3 : <CFString 0x3bf972c4 [0x3bf18ad0]>{contents = "ContainsAlpha"} = <CFBoolean 0x3bf18e88 [0x3bf18ad0]>{value = false}
5 : <CFString 0x3bf97184 [0x3bf18ad0]>{contents = "IOSurfaceOpenGLESFBOCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
7 : <CFString 0x3bf972d4 [0x3bf18ad0]>{contents = "Planes"} = <CFArray 0xb24830 [0x3bf18ad0]>{type = mutable-small, count = 2, values = (
0 : <CFBasicHash 0xb99420 [0x3bf18ad0]>{type = mutable dict, count = 3,
entries =>
0 : <CFString 0x3bf973b4 [0x3bf18ad0]>{contents = "FillExtendedPixelsCallback"} = <CFData 0xba06a0 [0x3bf18ad0]>{length = 12, capacity = 12, bytes = 0x00000000917cbb3100000000}
1 : <CFString 0x3bf97334 [0x3bf18ad0]>{contents = "BlackBlock"} = <CFData 0xb9deb0 [0x3bf18ad0]>{length = 1, capacity = 1, bytes = 0x10}
2 : <CFString 0x3bf97324 [0x3bf18ad0]>{contents = "BitsPerBlock"} = <CFNumber 0xb277e0 [0x3bf18ad0]>{value = +8, type = kCFNumberSInt32Type}
}
1 : <CFBasicHash 0xba0e50 [0x3bf18ad0]>{type = mutable dict, count = 5,
entries =>
0 : <CFString 0x3bf97334 [0x3bf18ad0]>{contents = "BlackBlock"} = <CFData 0xb9c550 [0x3bf18ad0]>{length = 2, capacity = 2, bytes = 0x8080}
2 : <CFString 0x3bf97344 [0x3bf18ad0]>{contents = "HorizontalSubsampling"} = <CFNumber 0xc0f720 [0x3bf18ad0]>{value = +2, type = kCFNumberSInt32Type}
4 : <CFString 0x3bf97324 [0x3bf18ad0]>{contents = "BitsPerBlock"} = <CFNumber 0xba0e80 [0x3bf18ad0]>{value = +16, type = kCFNumberSInt32Type}
5 : <CFString 0x3bf973b4 [0x3bf18ad0]>{contents = "FillExtendedPixelsCallback"} = <CFData 0xba16d0 [0x3bf18ad0]>{length = 12, capacity = 12, bytes = 0x00000000817bbb3100000000}
6 : <CFString 0x3bf97354 [0x3bf18ad0]>{contents = "VerticalSubsampling"} = <CFNumber 0xc0f720 [0x3bf18ad0]>{value = +2, type = kCFNumberSInt32Type}
}
)}
8 : <CFString 0x3bf97294 [0x3bf18ad0]>{contents = "PixelFormat"} = <CFNumber 0xb7acf0 [0x3bf18ad0]>{value = +875704438, type = kCFNumberSInt32Type}
12 : <CFString 0x3bf97174 [0x3bf18ad0]>{contents = "IOSurfaceOpenGLESTextureCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
}
}
propagatedAttachments=<CFBasicHash 0x12638c10 [0x3bf18ad0]>{type = mutable dict, count = 4,
entries =>
1 : <CFString 0x3bf70edc [0x3bf18ad0]>{contents = "MetadataDictionary"} = <CFBasicHash 0x12638650 [0x3bf18ad0]>{type = mutable dict, count = 7,
entries =>
0 : <CFString 0x3bf70f4c [0x3bf18ad0]>{contents = "SNR"} = <CFNumber 0x126367e0 [0x3bf18ad0]>{value = +34.16280207318401096472, type = kCFNumberFloat64Type}
2 : <CFString 0x3bf70ddc [0x3bf18ad0]>{contents = "sensorDGain"} = <CFNumber 0x12633120 [0x3bf18ad0]>{value = +256, type = kCFNumberSInt32Type}
3 : <CFString 0x3bf70f3c [0x3bf18ad0]>{contents = "SensorID"} = <CFNumber 0x126360c0 [0x3bf18ad0]>{value = +38754, type = kCFNumberSInt32Type}
6 : <CFString 0x3bf7054c [0x3bf18ad0]>{contents = "ExposureTime"} = <CFNumber 0x12636440 [0x3bf18ad0]>{value = +0.02999900000000000136, type = kCFNumberFloat64Type}
7 : <CFString 0x3bf70dec [0x3bf18ad0]>{contents = "ispDGain"} = <CFNumber 0x12630f20 [0x3bf18ad0]>{value = +260, type = kCFNumberSInt32Type}
11 : <CFString 0x3bf7017c [0x3bf18ad0]>{contents = "AGC"} = <CFNumber 0xd580830 [0x3bf18ad0]>{value = +1803, type = kCFNumberSInt32Type}
12 : <CFString 0x3bf7114c [0x3bf18ad0]>{contents = "AEAverage"} = <CFNumber 0x12635ae0 [0x3bf18ad0]>{value = +176, type = kCFNumberSInt32Type}
}
3 : <CFString 0x3bf96f54 [0x3bf18ad0]>{contents = "CVImageBufferYCbCrMatrix"} = <CFString 0x126383d0 [0x3bf18ad0]>{contents = "ITU_R_601_4"}
5 : <CFString 0x3bf96f94 [0x3bf18ad0]>{contents = "CVImageBufferColorPrimaries"} = <CFString 0x12632d90 [0x3bf18ad0]>{contents = "ITU_R_709_2"}
6 : <CFString 0x3bf96fd4 [0x3bf18ad0]>{contents = "CVImageBufferTransferFunction"} = <CFString 0x126372c0 [0x3bf18ad0]>{contents = "ITU_R_709_2"}
}
nonPropagatedAttachments=<CFBasicHash 0x12638be0 [0x3bf18ad0]>{type = mutable dict, count = 0,
entries =>
}
>
As Spectravideo328 has mentioned the byte per row isn't the same as width of the image. Hence you'll need to copy the valid data from the source layers to your destination buffer skipping the extra paddings. That means for each row (which is equal to the "height" of the image) copy the first "width" amount of bytes.
Related
while loop in my program does not fill the second row
I have 2 inner while loops. Code writes the results to first row on the matrix but when it gets to second row, it just passes the other rows and doesn't fill the columns of the rows. How to solve it? The code and output are like below: while i <= m-1 i while a <= m-1 a den1 = sqrt(((xy{i,j}-xy{a+1,b})^2+(xy{i,j+1}-xy{a+1,b+1})^2 )); dMat(i,a) = den1; a = a+1; end i = i+1; end i = 1 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 7 a = 8 a = 9 a = 10 a = 11 a = 12 a = 13 a = 14 a = 15 a = 16 a = 17 a = 18 a = 19 a = 20 a = 21 a = 22 a = 23 a = 24 i = 2 i = 3 i = 4 i = 5 i = 6 i = 7 i = 8 i = 9 i = 10 i = 11 i = 12 i = 13 i = 14 i = 15 i = 16 i = 17 i = 18 i = 19 i = 20 i = 21 i = 22 i = 23 i = 24
You have to restart a to a=1 for each iteration. Put it above the while a <= m-1
Neural Network Recognising in Scilab
I try to run this example, which uses ANN Toolbox for Scilab https://burubaxair.wordpress.com/2014/03/12/artificial-neural-networks-in-scilab/ This is code: T = [ 1 1 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 ]'; U = [ 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 1 1 1 0 ]'; N = [35 10 2]; W = ann_FF_init(N); x = [1, 0, 0, 0, 1; 1, 0, 0, 0, 1; 1, 0, 0, 0, 1; 1, 0, 0, 0, 1; 1, 0, 0, 0, 1; 1, 0, 0, 0, 1; 0, 1, 1, 1, 0]'; t_t = [1 0]'; t_u = [0 1]'; t = [t_t, t_u]; lp = [0.01, 1e-4]; epochs = 3000; W = ann_FF_Std_batch(x,t,N,W,lp,epochs); y = ann_FF_run(x,N,W) disp(y) But i receive an error: -->exec('D:\Учёба\Задачи\Recognition.sce', -1) !--error 15 Подматрица задана некорректно (Submatrix is incorrect). at line 37 of function ann_FF_grad_BP called by : at line 25 of function ann_FF_Std_batch called by : W = ann_FF_Std_batch(x,t,N,W,lp,epochs); at line 33 of exec file called by : exec('D:\Учёба\Задачи\Recognition.sce', -1) An error may be in T and U matrix, but i don't understand why. Could you tell be what i do wrong? Thank you!
You've made 2 errors in your code: You should not mix testing and training sets. Testing input must be a single column. Your first error was x = [ 1.... ] because it contained a single image, whereas you specified in N that you had two output neurons. As stated in the example, you should have x = [T,U]; Your second error was to give x as a test to ann_FF_run. This function takes test input as a single column. But since you trained your NN with x just before it was a 5x7 matrix. Just change it to a column vector. Here a corrected and commented code : T = [... 1 1 1 1 1 ... 0 0 1 0 0 ... 0 0 1 0 0 ... 0 0 1 0 0 ... 0 0 1 0 0 ... 0 0 1 0 0 ... 0 0 1 0 0 ... ]'; U = [... 1 0 0 0 1 ... 1 0 0 0 1 ... 1 0 0 0 1 ... 1 0 0 0 1 ... 1 0 0 0 1 ... 1 0 0 0 1 ... 0 1 1 1 0 ... ]'; // setting the traing set of two image xtrain = [T,U]; // so each image as 35 pixels so N(1) is 35 // and we have two images so N($) is 2 N = [35 10 2]; // training the NN W = ann_FF_init(N); // The expected response for T : 1 for T, 0 for U t_t = [1 0]'; // The expected response for T : 1 for T, 0 for U t_u = [0 1]'; // the overall response t = [t_t, t_u]; // some parameters lp = [0.01, 1e-4]; epochs = 3000; // getting the weight of the trained NN W = ann_FF_Std_batch(xtrain,t,N,W,lp,epochs); // testing the traing set. y = ann_FF_run(xtrain,N,W) disp('Testing the traing set') disp(y) //should get something close to t ~ [1 0 ; 0 1] // testing a distord U xtest1 = matrix([1, 0, 0, 0, 1; 1, 1, 0, 0, 1; 1, 0, 0, 0, 1; 1, 0, 0, 0, 1; 1, 0, 0, 0, 1; 1, 0, 0, 0, 1; 0, 1, 1, 1, 1]',-1,1); y = ann_FF_run(xtest1,N,W) disp('Testing a distored U') disp(y) //should get something close to t_u ~ [0 1] //testing something different from T and U. should get nothing xtest2 = matrix([1, 0, 0, 0, 1; 1, 1, 0, 0, 1; 1, 0, 1, 0, 1; 1, 0, 1, 0, 1; 0, 0, 1, 1, 1; 0, 0, 1, 0, 1; 0, 1, 1, 1, 1]',-1,1); y = ann_FF_run(xtest2,N,W) disp('Testing something neither T nor U') disp(y) and the output from scilab's console Testing the traing set 0.8538757 0.1075397 0.1393287 0.8957439 Testing a distored U 0.1078667 0.9007755 Testing something neither T nor U 0.3433933 0.6306797
Matching a string in one file and want to print the value written after that string in certain file
Code: use strict; use warnings; open(my $file, "<", "abc.txt") || die ("Cannot open file.\n"); open(my $out, ">", "output.txt") || die ("Cannot open file.\n"); while (my $line =<$file>) { chomp $line; if ($line =~ /\+vth\d = (\d+)/) { print $out "$1\n"; } } abc.txt .lib cmos_models .model nmos nmos level = 54 +version = 4.0 binunit = 1 paramchk= 1 mobmod = 0 +capmod = 2 igcmod = 1 igbmod = 1 geomod = 1 +diomod = 1 rdsmod = 0 rbodymod= 1 rgatemod= 1 +permod = 1 acnqsmod= 0 trnqsmod= 0 +tnom = 27 toxe = 1.75e-9 toxp = 1.1e-9 toxm = 1.75e-9 +dtox = 0.65e-9 epsrox = 3.9 wint = 5e-009 lint = 3.75e-009 +ll = 0 wl = 0 lln = 1 wln = 1 +lw = 0 ww = 0 lwn = 1 wwn = 1 +lwl = 0 wwl = 0 xpart = 0 toxref = 1.75e-9 +xl = -20e-9 +vth0 = 0.466 k1 = 0.4 k2 = 0.0 k3 = 0 +k3b = 0 w0 = 2.5e-006 dvt0 = 1 dvt1 = 2 +dvt2 = 0 dvt0w = 0 dvt1w = 0 dvt2w = 0 +dsub = 0.1 minv = 0.05 voffl = 0 dvtp0 = 1.0e-010 +dvtp1 = 0.1 lpe0 = 0 lpeb = 0 xj = 1.4e-008 +ngate = 2e+020 ndep = 3.24e+018 nsd = 2e+020 phin = 0 +cdsc = 0.000 cdscb = 0 cdscd = 0 cit = 0 +voff = -0.13 nfactor = 2.1 eta0 = 0.0049 etab = 0 +vfb = -0.55 u0 = 0.04398 ua = 6e-010 ub = 1.2e-018 +uc = 0 vsat = 147390 a0 = 1.0 ags = 0 +a1 = 0 a2 = 1.0 b0 = 0 b1 = 0 +keta = 0.04 dwg = 0 dwb = 0 pclm = 0.02 +pdiblc1 = 0.001 pdiblc2 = 0.001 pdiblcb = -0.005 drout = 0.5 +pvag = 1e-020 delta = 0.01 pscbe1 = 8.14e+008 pscbe2 = 1e-007 +fprout = 0.2 pdits = 0.08 pditsd = 0.23 pditsl = 2.3e+006 +rsh = 5 rdsw = 155 rsw = 80 rdw = 80 +rdswmin = 0 rdwmin = 0 rswmin = 0 prwg = 0 +prwb = 0 wr = 1 alpha0 = 0.074 alpha1 = 0.005 +beta0 = 30 agidl = 0.0002 bgidl = 2.1e+009 cgidl = 0.0002 +egidl = 0.8 +aigbacc = 0.012 bigbacc = 0.0028 cigbacc = 0.002 +nigbacc = 1 aigbinv = 0.014 bigbinv = 0.004 cigbinv = 0.004 +eigbinv = 1.1 nigbinv = 3 aigc = 0.012 bigc = 0.0028 +cigc = 0.002 aigsd = 0.012 bigsd = 0.0028 cigsd = 0.002 +nigc = 1 poxedge = 1 pigcd = 1 ntox = 1 +xrcrg1 = 12 xrcrg2 = 5 +cgso = 1.1e-010 cgdo = 1.1e-010 cgbo = 2.56e-011 cgdl = 2.653e-10 +cgsl = 2.653e-10 ckappas = 0.03 ckappad = 0.03 acde = 1 +moin = 15 noff = 0.9 voffcv = 0.02 +kt1 = -0.11 kt1l = 0 kt2 = 0.022 ute = -1.5 +ua1 = 4.31e-009 ub1 = 7.61e-018 uc1 = -5.6e-011 prt = 0 +at = 33000 +fnoimod = 1 tnoimod = 0 +jss = 0.0001 jsws = 1e-011 jswgs = 1e-010 njs = 1 +ijthsfwd= 0.01 ijthsrev= 0.001 bvs = 10 xjbvs = 1 +jsd = 0.0001 jswd = 1e-011 jswgd = 1e-010 njd = 1 +ijthdfwd= 0.01 ijthdrev= 0.001 bvd = 10 xjbvd = 1 +pbs = 1 cjs = 0.0005 mjs = 0.5 pbsws = 1 +cjsws = 5e-010 mjsws = 0.33 pbswgs = 1 cjswgs = 3e-010 +mjswgs = 0.33 pbd = 1 cjd = 0.0005 mjd = 0.5 +pbswd = 1 cjswd = 5e-010 mjswd = 0.33 pbswgd = 1 +cjswgd = 5e-010 mjswgd = 0.33 tpb = 0.005 tcj = 0.001 +tpbsw = 0.005 tcjsw = 0.001 tpbswg = 0.005 tcjswg = 0.001 +xtis = 3 xtid = 3 +dmcg = 0e-006 dmci = 0e-006 dmdg = 0e-006 dmcgt = 0e-007 +dwj = 0.0e-008 xgw = 0e-007 xgl = 0e-008 +rshg = 0.4 gbmin = 1e-010 rbpb = 5 rbpd = 15 +rbps = 15 rbdb = 15 rbsb = 15 ngcon = 1 * PTM 45nm PMOS .model pmos pmos level = 54 +version = 4.0 binunit = 1 paramchk= 1 mobmod = 0 +capmod = 2 igcmod = 1 igbmod = 1 geomod = 1 +diomod = 1 rdsmod = 0 rbodymod= 1 rgatemod= 1 +permod = 1 acnqsmod= 0 trnqsmod= 0 +tnom = 27 toxe = 1.85e-009 toxp = 1.1e-009 toxm = 1.85e-009 +dtox = 0.75e-9 epsrox = 3.9 wint = 5e-009 lint = 3.75e-009 +ll = 0 wl = 0 lln = 1 wln = 1 +lw = 0 ww = 0 lwn = 1 wwn = 1 +lwl = 0 wwl = 0 xpart = 0 toxref = 1.85e-009 +xl = -20e-9 +vth0 = 40 k1 = 0.4 k2 = -0.01 k3 = 0 +k3b = 0 w0 = 2.5e-006 dvt0 = 1 dvt1 = 2 +dvt2 = -0.032 dvt0w = 0 dvt1w = 0 dvt2w = 0 +dsub = 0.1 minv = 0.05 voffl = 0 dvtp0 = 1e-011 +dvtp1 = 0.05 lpe0 = 0 lpeb = 0 xj = 1.4e-008 +ngate = 2e+020 ndep = 2.44e+018 nsd = 2e+020 phin = 0 +cdsc = 0.000 cdscb = 0 cdscd = 0 cit = 0 +voff = -0.126 nfactor = 2.1 eta0 = 0.0049 etab = 0 +vfb = 0.55 u0 = 0.00440 ua = 2.0e-009 ub = 0.5e-018 +uc = 0 vsat = 70000 a0 = 1.0 ags = 1e-020 +a1 = 0 a2 = 1 b0 = 0 b1 = 0 +keta = -0.047 dwg = 0 dwb = 0 pclm = 0.12 +pdiblc1 = 0.001 pdiblc2 = 0.001 pdiblcb = 3.4e-008 drout = 0.56 +pvag = 1e-020 delta = 0.01 pscbe1 = 8.14e+008 pscbe2 = 9.58e-007 +fprout = 0.2 pdits = 0.08 pditsd = 0.23 pditsl = 2.3e+006 +rsh = 5 rdsw = 155 rsw = 75 rdw = 75 +rdswmin = 0 rdwmin = 0 rswmin = 0 prwg = 0 +prwb = 0 wr = 1 alpha0 = 0.074 alpha1 = 0.005 +beta0 = 30 agidl = 0.0002 bgidl = 2.1e+009 cgidl = 0.0002 +egidl = 0.8 +aigbacc = 0.012 bigbacc = 0.0028 cigbacc = 0.002 +nigbacc = 1 aigbinv = 0.014 bigbinv = 0.004 cigbinv = 0.004 +eigbinv = 1.1 nigbinv = 3 aigc = 0.69 bigc = 0.0012 +cigc = 0.0008 aigsd = 0.0087 bigsd = 0.0012 cigsd = 0.0008 +nigc = 1 poxedge = 1 pigcd = 1 ntox = 1 +xrcrg1 = 12 xrcrg2 = 5 +cgso = 1.1e-010 cgdo = 1.1e-010 cgbo = 2.56e-011 cgdl = 2.653e-10 +cgsl = 2.653e-10 ckappas = 0.03 ckappad = 0.03 acde = 1 +moin = 15 noff = 0.9 voffcv = 0.02 +kt1 = -0.11 kt1l = 0 kt2 = 0.022 ute = -1.5 +ua1 = 4.31e-009 ub1 = 7.61e-018 uc1 = -5.6e-011 prt = 0 +at = 33000 +fnoimod = 1 tnoimod = 0 +jss = 0.0001 jsws = 1e-011 jswgs = 1e-010 njs = 1 +ijthsfwd= 0.01 ijthsrev= 0.001 bvs = 10 xjbvs = 1 +jsd = 0.0001 jswd = 1e-011 jswgd = 1e-010 njd = 1 +ijthdfwd= 0.01 ijthdrev= 0.001 bvd = 10 xjbvd = 1 +pbs = 1 cjs = 0.0005 mjs = 0.5 pbsws = 1 +cjsws = 5e-010 mjsws = 0.33 pbswgs = 1 cjswgs = 3e-010 +mjswgs = 0.33 pbd = 1 cjd = 0.0005 mjd = 0.5 +pbswd = 1 cjswd = 5e-010 mjswd = 0.33 pbswgd = 1 +cjswgd = 5e-010 mjswgd = 0.33 tpb = 0.005 tcj = 0.001 +tpbsw = 0.005 tcjsw = 0.001 tpbswg = 0.005 tcjswg = 0.001 +xtis = 3 xtid = 3 +dmcg = 0e-006 dmci = 0e-006 dmdg = 0e-006 dmcgt = 0e-007 +dwj = 0.0e-008 xgw = 0e-007 xgl = 0e-008 +rshg = 0.4 gbmin = 1e-010 rbpb = 5 rbpd = 15 +rbps = 15 rbdb = 15 rbsb = 15 ngcon = 1 .model pmos pmos level = 54 +version = 4.0 binunit = 1 paramchk= 1 mobmod = 0 +capmod = 2 igcmod = 1 igbmod = 1 geomod = 1 +diomod = 1 rdsmod = 0 rbodymod= 1 rgatemod= 1 +permod = 1 acnqsmod= 0 trnqsmod= 0 +tnom = 27 toxe = 1.85e-009 toxp = 1.1e-009 toxm = 1.85e-009 +dtox = 0.75e-9 epsrox = 3.9 wint = 5e-009 lint = 3.75e-009 +ll = 0 wl = 0 lln = 1 wln = 1 +lw = 0 ww = 0 lwn = 1 wwn = 1 +lwl = 0 wwl = 0 xpart = 0 toxref = 1.85e-009 +xl = -20e-9 +vth0 = 50 k1 = 0.4 k2 = -0.01 k3 = 0 +k3b = 0 w0 = 2.5e-006 dvt0 = 1 dvt1 = 2 +dvt2 = -0.032 dvt0w = 0 dvt1w = 0 dvt2w = 0 +dsub = 0.1 minv = 0.05 voffl = 0 dvtp0 = 1e-011 +dvtp1 = 0.05 lpe0 = 0 lpeb = 0 xj = 1.4e-008 +ngate = 2e+020 ndep = 2.44e+018 nsd = 2e+020 phin = 0 +cdsc = 0.000 cdscb = 0 cdscd = 0 cit = 0 +voff = -0.126 nfactor = 2.1 eta0 = 0.0049 etab = 0 +vfb = 0.55 u0 = 0.00440 ua = 2.0e-009 ub = 0.5e-018 +uc = 0 vsat = 70000 a0 = 1.0 ags = 1e-020 +a1 = 0 a2 = 1 b0 = 0 b1 = 0 +keta = -0.047 dwg = 0 dwb = 0 pclm = 0.12 +pdiblc1 = 0.001 pdiblc2 = 0.001 pdiblcb = 3.4e-008 drout = 0.56 +pvag = 1e-020 delta = 0.01 pscbe1 = 8.14e+008 pscbe2 = 9.58e-007 +fprout = 0.2 pdits = 0.08 pditsd = 0.23 pditsl = 2.3e+006 +rsh = 5 rdsw = 155 rsw = 75 rdw = 75 +rdswmin = 0 rdwmin = 0 rswmin = 0 prwg = 0 +prwb = 0 wr = 1 alpha0 = 0.074 alpha1 = 0.005 +beta0 = 30 agidl = 0.0002 bgidl = 2.1e+009 cgidl = 0.0002 +egidl = 0.8 +aigbacc = 0.012 bigbacc = 0.0028 cigbacc = 0.002 +nigbacc = 1 aigbinv = 0.014 bigbinv = 0.004 cigbinv = 0.004 +eigbinv = 1.1 nigbinv = 3 aigc = 0.69 bigc = 0.0012 +cigc = 0.0008 aigsd = 0.0087 bigsd = 0.0012 cigsd = 0.0008 +nigc = 1 poxedge = 1 pigcd = 1 ntox = 1 +xrcrg1 = 12 xrcrg2 = 5 +cgso = 1.1e-010 cgdo = 1.1e-010 cgbo = 2.56e-011 cgdl = 2.653e-10 +cgsl = 2.653e-10 ckappas = 0.03 ckappad = 0.03 acde = 1 +moin = 15 noff = 0.9 voffcv = 0.02 +kt1 = -0.11 kt1l = 0 kt2 = 0.022 ute = -1.5 +ua1 = 4.31e-009 ub1 = 7.61e-018 uc1 = -5.6e-011 prt = 0 +at = 33000 +fnoimod = 1 tnoimod = 0 +jss = 0.0001 jsws = 1e-011 jswgs = 1e-010 njs = 1 +ijthsfwd= 0.01 ijthsrev= 0.001 bvs = 10 xjbvs = 1 +jsd = 0.0001 jswd = 1e-011 jswgd = 1e-010 njd = 1 +ijthdfwd= 0.01 ijthdrev= 0.001 bvd = 10 xjbvd = 1 +pbs = 1 cjs = 0.0005 mjs = 0.5 pbsws = 1 +cjsws = 5e-010 mjsws = 0.33 pbswgs = 1 cjswgs = 3e-010 +mjswgs = 0.33 pbd = 1 cjd = 0.0005 mjd = 0.5 +pbswd = 1 cjswd = 5e-010 mjswd = 0.33 pbswgd = 1 +cjswgd = 5e-010 mjswgd = 0.33 tpb = 0.005 tcj = 0.001 +tpbsw = 0.005 tcjsw = 0.001 tpbswg = 0.005 tcjswg = 0.001 +xtis = 3 xtid = 3 +dmcg = 0e-006 dmci = 0e-006 dmdg = 0e-006 dmcgt = 0e-007 +dwj = 0.0e-008 xgw = 0e-007 xgl = 0e-008 +rshg = 0.4 gbmin = 1e-010 rbpb = 5 rbpd = 15 +rbps = 15 rbdb = 15 rbsb = 15 ngcon = 1 .model pmos pmos level = 54 +version = 4.0 binunit = 1 paramchk= 1 mobmod = 0 +capmod = 2 igcmod = 1 igbmod = 1 geomod = 1 +diomod = 1 rdsmod = 0 rbodymod= 1 rgatemod= 1 +permod = 1 acnqsmod= 0 trnqsmod= 0 +tnom = 27 toxe = 1.85e-009 toxp = 1.1e-009 toxm = 1.85e-009 +dtox = 0.75e-9 epsrox = 3.9 wint = 5e-009 lint = 3.75e-009 +ll = 0 wl = 0 lln = 1 wln = 1 +lw = 0 ww = 0 lwn = 1 wwn = 1 +lwl = 0 wwl = 0 xpart = 0 toxref = 1.85e-009 +xl = -20e-9 +vth0 = 60 k1 = 0.4 k2 = -0.01 k3 = 0 +k3b = 0 w0 = 2.5e-006 dvt0 = 1 dvt1 = 2 +dvt2 = -0.032 dvt0w = 0 dvt1w = 0 dvt2w = 0 +dsub = 0.1 minv = 0.05 voffl = 0 dvtp0 = 1e-011 +dvtp1 = 0.05 lpe0 = 0 lpeb = 0 xj = 1.4e-008 +ngate = 2e+020 ndep = 2.44e+018 nsd = 2e+020 phin = 0 +cdsc = 0.000 cdscb = 0 cdscd = 0 cit = 0 +voff = -0.126 nfactor = 2.1 eta0 = 0.0049 etab = 0 +vfb = 0.55 u0 = 0.00440 ua = 2.0e-009 ub = 0.5e-018 +uc = 0 vsat = 70000 a0 = 1.0 ags = 1e-020 +a1 = 0 a2 = 1 b0 = 0 b1 = 0 +keta = -0.047 dwg = 0 dwb = 0 pclm = 0.12 +pdiblc1 = 0.001 pdiblc2 = 0.001 pdiblcb = 3.4e-008 drout = 0.56 +pvag = 1e-020 delta = 0.01 pscbe1 = 8.14e+008 pscbe2 = 9.58e-007 +fprout = 0.2 pdits = 0.08 pditsd = 0.23 pditsl = 2.3e+006 +rsh = 5 rdsw = 155 rsw = 75 rdw = 75 +rdswmin = 0 rdwmin = 0 rswmin = 0 prwg = 0 +prwb = 0 wr = 1 alpha0 = 0.074 alpha1 = 0.005 +beta0 = 30 agidl = 0.0002 bgidl = 2.1e+009 cgidl = 0.0002 +egidl = 0.8 +aigbacc = 0.012 bigbacc = 0.0028 cigbacc = 0.002 +nigbacc = 1 aigbinv = 0.014 bigbinv = 0.004 cigbinv = 0.004 +eigbinv = 1.1 nigbinv = 3 aigc = 0.69 bigc = 0.0012 +cigc = 0.0008 aigsd = 0.0087 bigsd = 0.0012 cigsd = 0.0008 +nigc = 1 poxedge = 1 pigcd = 1 ntox = 1 +xrcrg1 = 12 xrcrg2 = 5 +cgso = 1.1e-010 cgdo = 1.1e-010 cgbo = 2.56e-011 cgdl = 2.653e-10 +cgsl = 2.653e-10 ckappas = 0.03 ckappad = 0.03 acde = 1 +moin = 15 noff = 0.9 voffcv = 0.02 +kt1 = -0.11 kt1l = 0 kt2 = 0.022 ute = -1.5 +ua1 = 4.31e-009 ub1 = 7.61e-018 uc1 = -5.6e-011 prt = 0 +at = 33000 +fnoimod = 1 tnoimod = 0 +jss = 0.0001 jsws = 1e-011 jswgs = 1e-010 njs = 1 +ijthsfwd= 0.01 ijthsrev= 0.001 bvs = 10 xjbvs = 1 +jsd = 0.0001 jswd = 1e-011 jswgd = 1e-010 njd = 1 +ijthdfwd= 0.01 ijthdrev= 0.001 bvd = 10 xjbvd = 1 +pbs = 1 cjs = 0.0005 mjs = 0.5 pbsws = 1 +cjsws = 5e-010 mjsws = 0.33 pbswgs = 1 cjswgs = 3e-010 +mjswgs = 0.33 pbd = 1 cjd = 0.0005 mjd = 0.5 +pbswd = 1 cjswd = 5e-010 mjswd = 0.33 pbswgd = 1 +cjswgd = 5e-010 mjswgd = 0.33 tpb = 0.005 tcj = 0.001 +tpbsw = 0.005 tcjsw = 0.001 tpbswg = 0.005 tcjswg = 0.001 +xtis = 3 xtid = 3 +dmcg = 0e-006 dmci = 0e-006 dmdg = 0e-006 dmcgt = 0e-007 +dwj = 0.0e-008 xgw = 0e-007 xgl = 0e-008 +rshg = 0.4 gbmin = 1e-010 rbpb = 5 rbpd = 15 +rbps = 15 rbdb = 15 rbsb = 15 ngcon = 1 .endl There are 4 vth0 in file. At least 4 spaces between vth0 and =, at least one space between = and corresponding value. One more thing what if I need to read only last 3 vth0 values, skipping first one. What changes I have to make.
There are more than one whitespace after vth\d and you are matching just one whitespace. You should match all whitespaces: #!/usr/bin/perl use strict; use warnings; open(my $file, "<", "abc.txt") || die ("Cannot open file.\n"); open(my $out, ">", "output.txt") || die ("Cannot open file.\n"); while (my $line = <$file>) { chomp $line; if ($line =~ /\+vth\d\s+=\s+(\d+)/) { print $out "$1\n"; } } Here \s+ will match one or more whitespaces. Output: 0 40 50 60
Use \s in a regex to match whitespace. If you want to skip the first occurrence, keep a flag that tells you whether it was already skipped: my $skip = 1; while (<$INPUT>) { if (/vth\d\s*=\s*(\d+)/) { if ($skip) { undef $skip; # Don't skip the following occurences. } else { print "$1\n"; } } }
At least 4 spaces between vth0 and =, at least one space between = and corresponding value. vth\d\s{4,}=\s+(\d+) read only last 3 vth0 values, skipping first one. Use a flag and if/else blocks to next on first match (or whatever condition you want)
Simplify the looping under two sets of conditions
I want to establish a pair of indices =[row col] where row = 4 * (n-1) + i and col = 4 * (m-1) + i Explanation for i, m and n: For n = 1 and m = 2, 3, 4, loop i = 1 : 4. For n = 2 and m = 1, loop i = 1 : 4. For n = 3 and m = 5, loop i = 1 : 4. The outcome should be: row = [1 1 1 2 2 2 3 3 3 4 4 4 5 6 7 8 9 10 11 12] col = [5 9 13 6 10 14 7 11 15 8 12 16 1 2 3 4 17 18 19 20] That is, I want to establish pairs of indices under different sets of n-m conditions. My trial: row = []; col = []; n = 1; for i = 1 : 4 for m = [2 3 4] row = [row 4 * (n - 1) + i]; col = [col 4 * (m - 1) + i]; end end n = 2; m = 1; for i = 1 : 4 row = [row 4 * (n - 1) + i]; col = [col 4 * (m - 1) + i]; end n= 3; m = 5; for i = 1 : 4 row = [row 4 * (n - 1) + i]; col = [col 4 * (m - 1) + i]; end This works but indeed I have many n-m conditions and the looping for i = 1 : 4 appeared repeatedly which seems that can be simplified. May I know if there are any elegant solutions to finish my objective? I appreciate for your help.
You can use a bsxfun based solution for all those three cases - ii = 1:4 row = reshape(bsxfun(#(A,B) 4 * (B-1) + A,ii,n'),1,[]) %//' col = reshape(bsxfun(#(A,B) 4 * (B-1) + A,ii,m'),1,[]) %//' The inputs would be as listed next. Case #1: m = [2, 3, 4] n = ones(1,numel(m)) Case #2: n = 2 m = 1 Case #3: n = 3 m = 5
I would create a Matrix with all parameters, then apply the math once: M=[...n m i ones(3,1) (2:4).' (1:3).';... 2*ones(4,1) ones(4,1) (1:4).';... 3*ones(4,1) 5*ones(4,1) (1:4).';... ]; row = (4 * (M(:,1) - 1) + M(:,3)).'; col = (4 * (M(:,2) - 1) + M(:,3)).'; %alternative: %index=(4 * (M(:,[1:2]) - 1) + M(:,[3,3])).'
NSArray containsObject NSString Not Working?
I hava an array list (RatingsList) containing below contents <CFArray 0x910e1a0 [0x2952380]>{type = mutable-small, count = 8, values = ( 0 : <CFString 0x910e0d0 [0x2952380]>{contents = "NR-Adult"} 1 : <CFString 0x910e0f0 [0x2952380]>{contents = "NC-17/TV-MA"} 2 : <CFString 0x910e110 [0x2952380]>{contents = "R"} 3 : <CFString 0x910e120 [0x2952380]>{contents = "PG-13/TV-14"} 4 : <CFString 0x910e140 [0x2952380]>{contents = "PG/TV-PG"} 5 : <CFString 0x910e160 [0x2952380]>{contents = "G/TV-G"} 6 : <CFString 0x910e170 [0x2952380]>{contents = "TV-Y/TV-Y7"} 7 : <CFString 0x910e190 [0x2952380]>{contents = "NR"} we are comparing for PG-13 [RatingsList containsObject:#"PG-13"] return false.
Of course it returns false. Your array doesn't contain "PG-13", although it does contain "PG-13/TV-14".
Use a simple NSPredicate. NSPredicate *predicate = [NSPredicate predicateWithFormat:#"SELF contains %#", aString]; NSArray *filteredArray = [RatingsList filteredArrayUsingPredicate:predicate]; if ([filteredArray count] > 0) return YES; return NO;